[Grok-dev] grok.Form and template files
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">
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>
else: outp += '<td></td>\r'
outp += '</tr>\r'
It works well, giving me control over the layout without any hassle.
8 nov 2007 kl. 18.05 skrev Thomas Lotze:
> we've noticed an inconvenience when using grok forms:
> If there is an appropriately named and located page template to be
> 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
> 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
> 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
> 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.
> Grok-dev mailing list
> Grok-dev at zope.org
More information about the Grok-dev