[jifty-devel] Rendering form_fields ?

myshare mraptor at gmail.com
Wed Mar 7 19:16:37 EST 2007


hmm.. I was thinking a while how to have the power of filling the data
from database, js-controlled hints,errors... and so on... and in the
same time control over the rendering of the widgets.
One of my ideas was something like this (this is just idea) :

have a ->render() accept something like template.Ex:

->render(q{&label  : &field<br>})

->render(q{
<div class="widget">
  <span class="label &classes">&label</span> :
  <span class="form_field &elem_classes">&label</span><br>
 <span class="error">&error</span>
</div>
})

->render(q{
  <td class="label">&label :</td>
  <td class="field">
  &field
  <div class="error">&error</div>
  &javascript_code
 </td>
})

or better yet setRender(q{..}), instead passing this on every invocation.
(one thing about this idea which didn't fit well is update/read mode,
m'I right ?)

and so on, u get the idea ..pass a template how u want the widget to
be rendered.
Then state !!CLEARLY!! in the docs which of the &data_methods are
required to provide specific functionality, so that the person can
decide which functionality is important to him.
One other thing I will very likely like :) is a catch all
functionality, what do I mean..
instead of putting f.e. &error and &javascript_code into every
element, have something like
&all_errors and &all_javascript_code, so that u do not put this into
every widget but on some separate place f.e. errors in some
footer-error-hint area, or Javascript's into <head>.

The good thing of this too is that putting your own "classes" you can
totaly remove Jifty formating if you don't like it. Currently I had to
go and read and understand all the css files, then read the
rendered-html ... and then remove what I feel is not good for me and
also put styles with zero-paddings/margins first to cancel some of the
formating then apply mine.
And even that sometimes doesn't work, because after app.css there is
more .css applied which still can break the things.(I had problem with
notices.css ;) )

I know that I oversimplify the things here and miss alot of the
processing that is going on behind the scenes like database access
when the form is in "update-render-mode" and ajax stuff, probably this
can be separated as some sort of data-source layer and also mixed on
the fly...dreaming here ;)

I looked at some of the code for ::Field:: to see I will I be able to
modify it easily to suit my needs, but I don't feel quite confident ;)

And one of my biggest concerns is : remove all Jifty->web->out() with
simple string concatenations that is flushed at the end.
There is two benefits of this : first you can intercept or get
specific data-token (like label,value, classes), next you can do some
regex-magic for a quick and dirty replacement..

Sorry if I make things seems simple..... ;)

PS. If we look at even more abstract way to this. The building of the
rendered widget, could be presented like walking a tree-structure and
filling the gaps with data, htm-tags and attributes. But how this can
be represented and processed, I have no good idea !!!

sorry for the long post

On 3/7/07, Jesse Vincent <jesse at bestpractical.com> wrote:
>
> > That is a very common case for me too. I need a lot of inelegant CSS
> > tricks to adjust the layout of preambles, labels, errors, and warnings
> > in my web forms, including explicit positioning. I hope we will have a
> > more flexible way to control the look and feel of the auto-generated
> > HTML code in the near future :)
>
> Do you have a pointer to something good we could emulate or learn from?


More information about the jifty-devel mailing list