[Zope3-Users] formlib - preloading data

2006-03-13 Thread David Johnson








I am experimenting with formlib, and Im stuck on one
point, how do you set the values of fields before they are rendered?



In my simple example, I simply have:



Form_fields = form.Fields(IContact)



How do I set the value of field before it is rendered?
Ive been playing with things like:

Form_fields[firstname] = uDavid 

(which doesnt work)



??



--

David Johnson








___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] formlib - preloading data

2006-03-13 Thread Fred Drake
On 3/14/06, David Johnson [EMAIL PROTECTED] 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
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users