[Zope] Using ZPT with options/radio/checkboxes

Paavo Parkkinen pparkkin at cc.jyu.fi
Thu Aug 7 07:25:21 EDT 2003


On ke, 06.08.2003 at 14:17 -0700, Chris Bruce wrote:

> For Instance:
> 
>                     <select name="question_type" id="question_type">
>                         <option value="Text" selected="selected">Text</option>
>                         <option value="TextArea">TextArea</option>
>                         <option value="ListSingle">ListSingle</option>
>                         <option value="ListMulti">ListMulti</option>
>                         <option value="ComboSingle">ComboSingle</option>
>                         <option value="Option">Option</option>
>                         <option value="Checkbox">Checkbox</option>
>                       </select>
> 
> If the question_type was in the REQUEST object, how would I evaluate which one was selected?

<select>
  <span tal:repeat="option options" tal:omit-tag="">
    <option tal:condition="python: option ==
                request.get('question_type')"
            selected="selected"
            tal:content="option"/>
    <option tal:condition="not:python: option ==
                request.get('question_type')"
            tal:content="option"/>
  </span>
</select>

> 
> Same goes for radio buttons:
>                     <input type="radio" name="required" value="1" /> Yes 
>                     <input name="required" type="radio" value="0" checked="checked" /> No
> 
> and the 'required' was in the REQUEST object.

<span tal:condition="python:request.get('required')" tal:omit-tag="">
  <input type="radio" name="required" value="1"
         checked="checked"/> Yes
  <input type="radio" name="required" value="0"/> No
</span>
<span tal:condition="not:python:request.get('required')" tal:omit-tag="">
  <input type="radio" name="required" value="1"/> Yes
  <input type="radio" name="required" value="0"
         checked="checked"/> No
</span>

-- 
paavo.

  "How convenient for you then that others have to work
   in a sweatshop so that you won't have to be poor..."



More information about the Zope mailing list