[Zope] Returning a ZPT form with fields filled in
robert rottermann
robert at redcor.ch
Sat Mar 13 03:51:08 EST 2004
I give you here an example how you can do it as a set of a pagetemplate
and an acociated script.
How to adapt it to your partiqular situation is up to you.
Robert
here a minimal form with one field:
As you can see values are collected first from the request.
They are put there when pass parameter trough the url like so:
http://myserver/mytemplate?first=robert&last=rottermann
if it they are not found not found there then the options are checked.
The parameters are put there when you call the template as a method in a
python script like so:
return mytemplate(first="robert", last="rottermann")
If neither of them yield a result nothing (which is an empty string in
this situation) is assigned.
The net result is, when you call the template the first time, an empty
form is presented,
when you press the submit butten the form is represented with its input
converted to lowercase.
<form action="myscript" "tal:define="
name request/first | options/first | nothing;
age request/last | options/last | nothing;">
<input name="first" type="text" tal:attributes="value first">
<input name="first" type="text" tal:attributes="value first">
<input type=submit">
</form>
Here the script myscript
## Script (Python) "myscript"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=frst, last
##title=
##
# do some processing
first = first.lower()
last = last.lower()
# call the page tamplate as function and pass parameters
return mytemplate(first=first, last=last)
Jan Van Uytven wrote:
>hey all,
>
>I have a page template that displays a list of rows from a database,
>along with a radio button on each row and an 'edit' button. When a radio
>button is selected and 'Edit' pressed, I want to send the user to
>another page that contains a form with all the values filled in with the
>data of that specific row, so the user can modify the information and
>submit the changes to the database.
>
>I've created the page that displays the rows, along with the radio
>button... I've also got the page with the form, and associated
>script/ZSQL method for updating the database.
>
>What I don't know how to do is the populate the form with the
>information I need. Can I use a python script to return the form page
>with the values filled in? How?
>
>BTW the forms are based on Formulator forms, if that helps or makes a
>difference.
>
>Much thanks,
>
>Jan
>
>
>---
>Jan (Wyvern) Van Uytven
>Sysadmin, UVic TRIUMF
>wyvern at uvic.ca
>
>Randomly selected from my quote-file:
>
>"Every revolution evaporates, leaving behind only
>the slime of a new bureaucracy."
> - Franz Kafka
>
>
>_______________________________________________
>Zope maillist - Zope at zope.org
>http://mail.zope.org/mailman/listinfo/zope
>** No cross posts or HTML encoding! **
>(Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>
>
>
>
More information about the Zope
mailing list