[Grok-dev] grok.Form and template files

Sebastian Ware sebastian at urbantalk.se
Fri Nov 9 07:25:55 EST 2007


Personally I like it the way it works now. I have my custom "auto- 
generation" method in the view class (render_form()) that is called by  
my page template

        <div id="edit_form" tal:content="structure view/render_form">
             The form...
        </div>

It basically revolves around:

	for widget in self.widgets:
             outp += '<tr class="row">\r'
             outp += '<td class="label"><label for="' + widget.name +  
'" title="' + widget.hint + '">'
             outp += widget.label + '</label></td>\r'
             outp += '<td class="field">' + widget() + '</td>\r'
             if widget.error() is not None:
                 outp += '<td class="error">' + widget.error() + '</td> 
\r'
             else: outp += '<td></td>\r'
             outp += '</tr>\r'

It works well, giving me control over the layout without any hassle.

Mvh Sebastian

8 nov 2007 kl. 18.05 skrev Thomas Lotze:

> Hi,
>
> we've noticed an inconvenience when using grok forms:
>
> If there is an appropriately named and located page template to be  
> found
> in the application package, a form will use it to render itself.  
> This is
> technically expected behaviour, forms being views. However, one often
> wants forms such as edit and add forms to render themselves rather  
> than
> typing all that widget and button stuff in a page template.
>
> It seems to happen often enough to be a nuisance, though, that one
> accidentally has a template lying around that gets picked up by a form
> while one expects the form to render itself - this bit us several  
> times
> when switching simple displays to edit forms, for example. We feel  
> this is
> a usability bug - maybe forms should make pick up page templates a  
> little
> less implicitly.
>
> What's other people's opinion? I'm tempted to file a bug unless I  
> get shot
> down for the idea now. Thanks for feedback in any case.
>
> -- 
> Thomas
>
>
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev



More information about the Grok-dev mailing list