[Zope] Form with variable number of inputs

Gustin Kiffney Gustin Kiffney" <Gustin_Kiffney@fd.org
Wed, 22 Dec 1999 10:20:42 -0500


I saw in zope.org's Documentation/How-to's an essay on how to create a
form with a variable number of inputs but it seemed a bit too
complicated for my simple mind.  I also read about the ':record' type
but its behavior doesn't seem useful in this case where some selections
in some rows might be left empty.  What I have is a table that may have
variable number of rows with listboxes of the same choices and text
input boxes in each row.  The user might change some or none of the
choices.  What I wound up doing is in each row having something like

<td><select name="lister:list" size="1">
<option value="Unassigned_Investigator">
<dtml-in get_all_inv_names>
  <option value="<dtml-var lastname"><dtml-var lastname></option>
</dtml-in>
</select>
</td>

which just means I coerced the 'lister' selection to be a list(in case
there were just one selection - the normal behavior for Zope when
several form variables have the same name 'joe' appears to be to turn
them into a list named 'joe'.

I also have a hidden field of 'ids' which is also a list and which is
in each row too.

So far when I get these list of 'ids' and 'lister' back, using Linux
Netscape 4 and Windows IE 4, they match up - in other words, the first
'ids' corresponds to the first 'lister', etc.  So I can figure out which
selection goes with which record/row.

So it seems that inputs with the same name are sent back to Zope 'in
order' at least with the browsers I use.  Is this a browser-dependent
thing or does Zope have some magic I don't know about that's doing
this?  Is my ignorance showing? (don't answer that!) I have a bunch more
forms I'm considering doing this way but I'm worried I'm just getting
lucky and this might not work in all situations/browsers.  Anyone know?