[Petal] option select in petal - ideas?

Christopher Heschong chris at wiw.org
Mon Apr 12 17:54:13 BST 2004


Lets say you have a select statement:

<select name="foo">
 <option tal:repeat="foo bar"
         tal:contents="foo/content"
         tal:attributes="selected foo/selected">option</option>
</select>

The problem is that there is no way for Petal to eliminate the selected
attribute if foo/selected returns false.  This is a problem because
selected="(anything)" causes the browser to assume that the option is
selected... the selected attribute must not exist at all in order for it
to not be selected.

Is the only way to do this something like:

<select name="foo">
 <span tal:repeat="foo bar">
   <span tal:condition="true:foo/selected">
    <option selected tal:contents="foo/content">option</option>
   </span>
   <span tal:condition="false:foo/selected">
    <option tal:contents="foo/content">option</option>
   </span>
 </span>
</select>

I guess the simple way to put it is can Petal be told to not print
attributes whose values are false or (better yet) nonexistant?


More information about the Petal mailing list