[Zope] TALs difficulties
Johan Carlsson
johanc at easypublisher.com
Wed Sep 1 08:45:19 EDT 2004
Hi,
I need help :-)
I'm trying to implement a new Widget for Archetypes.
So I have to write TAL (not my favorite hobby).
I'm extending the multi select widget with optgroup labels.
But I can figure out how to make the <option> contained by
the <optgroup> without breaking the XML code.
And I don't want to change the data format that's
used (which is a sub classed version of Archetypes
DisplayList that can mark items as optgroup labels,
indicated with a true value from isLabel).
Here's what I've settled for so far:
vocab is the DisplayList derivative (item is a key).
<tal:loop repeat="item vocab">
<optgroup
tal:attributes="label python:vocab.getValue(item);"
tal:condition="python:vocab.isLabel(item)">
</optgroup>
<option selected=""
tal:condition="not:python:vocab.isLabel(item)"
tal:attributes="value item;
selected python:test(here.unicodeTestIn(item, value),
'selected', None);"
tal:content="python: vocab.getValue(item)"/>
</tal:loop>
Returns something like this:
<optgroup label="A"></optgroup>
<option>Ada</option>
<option>Ape</option>
<optgroup label="B"></optgroup>
<option>Bananas</option>
<option>Buffy</option>
What I want is:
<optgroup label="A">
<option>Ada</option>
<option>Ape</option>
</optgroup>
<optgroup label="B">
<option>Bananas</option>
<option>Buffy</option>
</optgroup>
Which renders quite differently.
Best Regards,
Johan
More information about the Zope
mailing list