[Zope] javascript / python /populate fields from db
Satheesh Babu
vattekkat.babu@verizon.net
Wed, 23 Jul 2003 05:55:43 -0400
> My requirement is to populate three fields (coming
> from formulator) in a ZPT file. The first field has a
> drop down and should get data from db using pyhton.
> The next 2 fields should populate themselves with the
> corresponding columns from the database
Not sure why you would need Javascript. I'm assuming you have a
formulator form that you need to render using ZPT. Three fields in the
form have values from a database that is filled in.
You can use field.render(value=whatever, request=request.REQUEST) from
Formulator to fill in the values of the form.
eg: A python script gets all the values from a database or any other
place and returns a dictionary like {'fieldid':value...}. Let us call
this get_prefill_values().
So your ZPT will be, for Formulator form with id `form`:
<div tal:define="prefill here/get_prefill_values">
<div tal:repeat="field here/form/get_fields">
<span tal:replace="structure
python:field.render(value=prefill[field.id])"/>
</div>
</div>
HTH
--
Vattekkat S Babu
http://vsbabu.org/