[ZPT] Editing a field using select tag
Clemens Robbenhaar
robbenhaar at espresto.com
Sun May 18 18:19:52 EDT 2003
Santi Camps writes:
[...]
> But I have an existencial doubt. When I use ZPT to edit a record, and
> this record have one field represented with a select tag, I haven't
> found other way to do it that repeat de <option> tag with two opposite
> conditions. Like this:
>
> <select>
> <span tal:repeat="record loop" tal:omit-tag="">
> <option tal:content="record/title" tal:attributes="value record/id"
> tal:condition="is_current_record" SELECTED> </option>
> <option tal:content="record/title" tal:attributes="value record/id"
> tal:condition="is_not_current_record"> </option>
> </span>
> </select>
>
> Is there a better way to do this?
I do not think one needs to be an existencialist here ;-)
In similar cases I try something like:
<select>
<option selected
tal:repeat="record loop"
tal:content="record/title"
tal:attributes="
value record/id;
selected python:test(is_current_record, default, nothing)" />
</select>
If an attribute in the tal:attributes clause is set to "nothing";
it will not be rendered.
Using "default" for the "select" attributes renders the tag as
<option selected="selected' ...
I guess this is something that You may want. Only rendering
'<option selected ...' seems not to be supported, as it is no valid
XHTML, but even Netscape4 seems to understand the '<option select="selected"'
notation.
Cheers,
Clemens
More information about the ZPT
mailing list