[Zope] TAL::Selecting the current value in a select box

Chris Withers chrisw@nipltd.com
Fri, 31 May 2002 08:32:15 +0100


Luca Olivetti wrote:
> 
> > When loading my template I want to choose the correct value from the select
> > box. That is set the option SELECTED one of the options.
> 
>   <select>
>           <span tal:omit-tag="" tal:repeat="item here/SelectBoxData">
>              <option tal:attributes="value item/value;
>                             selected python:item.value==current_value"
>   tal:content="item/text"></option>
>           </span>
>   </select>
> 
> Should work

...or more neatly:

<select>
   <tal:r repeat="item here/SelectBoxData">
      <option tal:attributes="value    item/value;
                              selected python:item.value==current_value;"
              tal:content="item/text">Dummy Content</option>
   </tal:r>
</select>

cheers,

Chris