[ZPT] Looking for an answer to Sharing a form for both editing and
adding (formulator)
Exteam
exteam6 at yahoo.co.in
Mon Jul 21 15:23:47 EDT 2003
Hi,
I am looking for a solution to the problem of using both editing and adding using formulator. Ran into the following page, on the web, which asks the same question so well, that I am just quoting it here.
U can find it in the following link:
http://www.geocrawler.com/archives/3/12572/2002/11/0/10166843/
The problem is as follows:
How do people structure and name their Formulator forms and Zope trees so
the same form can be shared between add and edit functions? For example, if
I have an SQL table like so:
create table person (
last_name character varying(80),
first_name character varying(80),
middle_name character varying(80),
ssn character varying(80),
email character varying(80)
);
I'd like the same form to be usable for both adding new people and editing
the information for people already in the database. I'm using page
templates, so that might make a difference as well. Currently, I have a
structure which looks like this
person
form
add
index_html
input_form
do_action
edit
index_html
input_form
do_action
where "form" is a Formulator object, index_html displays either a blank or
filled in form using input_form, and do_action performs the necessary
database insert or update operations. Where should my form go and how
should I refer to fields? Though I use a single Formulator form, I wind up
duplicating the actual HTML <form> (in input_form) because in one case I use
the Formulator defaults and in the other case I fill in values for the
fields dredged from my database. In my add <form>:
<th class="form-label"
tal:content="python: here.utils.field_title(here.form.city)">title</th>
<td tal:content="structure here/form/city/render">item</td>
In my edit <form>:
<th class="form-label"
tal:content="python: here.utils.field_title(here.form.city)">title</th>
<td tal:content="structure python: here.form.city.render(options['city'])">item</td>
Lots of duplication, as you might imagine.
Also, do I need to use python: to pass a parameter to here/form/city/render
or can I do that somehow from ptl?
I realize this is probably more of a page template question, but you folks
are the ones who must want to share your forms, so I thought you'd have more
direct experience.
===========
looking forward for a quick response..
Regards
Subhankar
SMS using the Yahoo! Messenger;Download latest version.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.zope.org/pipermail/zpt/attachments/20030721/7032cd05/attachment.htm
More information about the ZPT
mailing list