[Zope3-Users] formlib - preloading data

Fred Drake fdrake at gmail.com
Tue Mar 14 00:46:28 EST 2006


On 3/14/06, David Johnson <djohnson at jsatech.com> wrote:
> I am experimenting with formlib, and I'm stuck on one point, how do you set
> the values of fields before they are rendered?
...
> How do I set the value of field before it is rendered?  I've been playing
> with things like:
>
> Form_fields['firstname'] = u'David'

The most basic approach is to extend the setUpWidgets() method:

    def setUpWidgets(self, ignore_request=False):
        super(MyFormClass, self).setUpWidgets(ignore_request=ignore_request)
        self.form_fields['firstname'].setRenderedValue(u'David')

Other ways to initialize the fields are documented in the form.txt
file in the zope.formlib package.  The add and edit forms usually do
the right thing for simple cases, and more elaborate form
initialization is pretty straightforward.


  -Fred

--
Fred L. Drake, Jr.    <fdrake at gmail.com>
"There is no wealth but life." --John Ruskin


More information about the Zope3-users mailing list