[Zope] Formulator - pre-selecting a line in a multiline field - still unsolved.

David Washburn dwashburn@aminfo.com
Wed, 23 Jul 2003 15:53:38 -0400


I am using a multiline Formulator widget and I want to preset the line in a
list using a value from the record in the database which I read in my DTML
document, and which is going to be updated. I read the record and I can
display all the "fixed" fields with no problems.

I am still not clear on how to specify the default value, which is gotten
from the database record, when I display the form using Formulator.

I have successfully created a Python/Script & ZSQL Method (it is in the
TALES Item field) to read a code table from a MySQL database and display it
in the Formulator form when it is rendered. This list has two values per
line, the text displayed and the numeric code that is to be returned when
the user make a choice from the list.

Dieter made a suggestion that I place the value of the data item that I want
to use to point to the correct line in the multiline widget, in a hidden
field so that it will be accessible when Formulator renders the field.

The document that displays the Formulator widgets is a DTML document that I
coded to display the data fields using calls to the Formulator API. The
lines look like this:

.....
<tr>
<td>
<input type="HIDDEN" name="company_contact_id_selected:int" value="<dtml-var
company_contact_id null="">">
<dtml-var "profile_form.company_contact_id.get_value('title')"></td>
<td><dtml-var
"profile_form.company_contact_id.render(_['company_contact_id'])"></td>
</tr>
.....

Which is rendered like this:
<tr>
<td>
<input type="HIDDEN" name="company_contact_id_selected:int" value="6">
ADVANCE Contact ID</td>
<td><select size="1" name="field_company_contact_id" ><option value="0"
>Unknown   </option>
<option value="22" >Sam (from: UK)</option>
<option value="26" >Bill (from: VN)</option>
<option value="6" >Bruce (from: SG)</option>
<option value="24" >Seth (from: US)</option>
</select>
</td>
</tr>

What I want to be able to do is have the line that displays "Bruce (from:
SG)" selected when the form is displayed since he is ID # 6. It should have
looked like this:

<option value="6" selected>Bruce (from: SG)</option>


The question is, what is the syntax I need to use in the Formulator/TALES
management screen for a multiline widget to reference the data in the hidden
field called "company_contact_id_selected".

I think I need to place a reference to the variable
"company_contact_id_selected" in the TALES default field, but I can't seem
to find the correct syntax to reference it.

Does anyone have any ideas?

Thanks,
David

=======================================
David T. Washburn DWashburn@AmInfo.com
Amherst, MA USA
413 256-3103