[Zope] Still Chipping Away At Formulator/ZPT Interface

Clemens Robbenhaar robbenhaar@espresto.com
Mon, 4 Nov 2002 22:33:09 +0100


 > >e.g. the equivalent to "<dtml-in> are "for" loops:
 > >
 > >  form = context.email_us_formulator
 > >  for fiels in form.fields():
 > >    print '<td>' + field.get_value('title') + '</td>'
 > 
 > Hmmm. This didn't work. It threw an AttributeError on *fields*. Just to be 
 > sure, I changed your line to
 > for x in form.fields():
 > and it was the form.fields() that was erroring. Why would it work in DTML 
 > and not in Python?

okok, maybe I should test the code myself or look up the online help
before I blow a posting to the list. :-/

The proper incantation should be:

  for field in form.get_fields():
    print '<td>' + field.get_value('title') + '</td>'

If You want to fix similar typos Yourself:  
 - go to the Formulator Form in the ZMI:
 - click "Help!" -> select "Formulator" -> select "APT Reference" -> select "Form"
 - read the text ;)