[Grok-dev] Re: Grok Widgets / Fields (Was Re: Re: [grok-br] Grok 1.0 and beyond)

Sebastian Ware sebastian at urbantalk.se
Thu Jan 10 10:37:16 EST 2008

I use formlib but never got into using a form template. Instead I went  
for the simple solution, where I iterate over the widgets and use  
widget() to generate each individual widget. Something like this:

	outp = '<form class="edit-form" enctype="multipart/form-data"  
method="post" action="" accept-charset="UTF-8">\r'
	outp += '<table>'
         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'
         outp += '</table>'
         outp += '</form>'	

Mvh Sebastian

10 jan 2008 kl. 15.31 skrev Luciano Ramalho:

> On Jan 10, 2008 10:45 AM, Martijn Faassen <faassen at startifact.com>  
> wrote:
>> Then again, zope.formlib is very nice when you do model-driven
>> development, ala CRUD.
> This is a great match for what I think Grok needs: easy model-driven
> development. However, I still have not figured out a good way to embed
> auto-generated forms in a master template.
> The form generation class in Django produces only the HTML for the
> contents of the <form> element, making it easy to embed. In Grok,
> auto-generated forms use a template
> (src/grok/templates/default_edit_form.pt) which include the entire
> HTML, HEAD and BODY, making it hard to embed.
> Cheers,
> Luciano
> _______________________________________________
> 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