[Zope] using form for add and edit help please.

Mark Lilly mark.lilly@conceracorp.com
Wed, 22 May 2002 16:11:25 -0700


Hi,
I am trying to use the same for for adding and editing.  If we are editing a
record, i want to insert its value. If we are adding, i want to have a blank
input text element.

Instead of having two input elements for each form element, i have come up
with this:
<td class="add" valign="top">
	<input type="hidden" name="prev_input_name" value="" />
	<input type="text" name="input_name" id="input_name" 
		tal:condition="exists:task/task_name | nothing"
		tal:attributes="value python:test(task, 'insert here',  '')"
/>            
</td>

Here is the code that fills the task variable:
<div tal:define="theTaskId request/task_id | string:0; task
python:root.CT.Scripts.P_Scripts.getTask(theTaskId)">

If task_id = 0, the python script will return an empty list. Otherwise, it
will return the 0th instance in the Catalog's collection.

I can't figure out what to put in place of 'insert here' in the above Input
element.  
I tried to use task/task_item but i get a NameError on global name
'task_item' is not defined.  
I tried getattr(task, 'task_name') but got an AttributeError on task_name.
I can't define a variable using task/task_name, because if it's empty, it
returns an error.
Any thoughts on how i can pull this off?
Thanks,
mark