[Zope] Help with DTML Forms
J Cameron Cooper
jccooper@jcameroncooper.com
Fri, 09 May 2003 17:26:35 -0500
>
> I would like to create a DTML Form that may be called with or without
> an argument (say, member_number). I have tried something like this, a
> DTML Form named AddAddressForm:
>
> <dtml-var standard_arfs_header>
>
> <dtml-form method=post action=AddAddress>
> <table>
> <dtml-unless member_number>
> <tr>
> <th>Member Number</th>
> <td><input type=text name=member_number></td>
> </tr>
> </dtml-unless>
> <tr>
> <th>Address</th>
> <th>City</th>
> </tr>
> <tr>
> <td><input type=text name=address type=string></td>
> <td><input type=text name=city type=string></td>
> </tr>
> <tr>
> <td colspan=2><input type=submit></td>
> </tr>
> </table>
> </dtml-form>
>
> My intent is to have a form that, if called with no input paramters,
> will display a field so I can enter the member_number. If the form is
> called with an input parameter, the member_number field will not be
> displayed, but the passed in value will be passed on to the AddAddress
> Method.
>
> ...
>
> Am I trying to do too much here? I could make two forms, but I don't
> like the idea of maintaining two nearly identical forms. Can this be
> done?
Try this...
<dtml-form method="post" action="AddAddress">
<table>
<dtml-if member_number>
<input type="hidden" name="member_number"
value="&dtml-member_number;" />
<dtml-else>
<tr>
<th>Member Number</th>
<td><input type=text name=member_number></td>
</tr>
</dtml-if>
<tr>
<th>Address</th>
<th>City</th>
</tr>
<tr>
<td><input type=text name=address type=string></td>
<td><input type=text name=city type=string></td>
</tr>
<tr>
<td colspan=2><input type=submit></td>
</tr>
</table>
</dtml-form>
I haven't done DTML in a while, so you may need to fix my if/else. If
the entity syntax won't work for you (and I don't know why it wouldn't),
you can use the normal form.
The hidden field trick is great for sequential pages.
--jcc
(better late than never)