[Zope] Using ZPT with options/radio/checkboxes
Ron Bickers
rbickers-expires-1060888233.9472c8 at logicetc.com
Thu Aug 7 16:09:57 EDT 2003
> -----Original Message-----
> From: zope-bounces at zope.org [mailto:zope-bounces at zope.org]On Behalf Of
> Paul Winkler
> I might write it like this:
>
> <input type="checkbox" name="toppings:list" value="Pepperoni"
> checked="checked"
> tal:attributes="checked python:test('Pepperoni' in
> request.get('toppings', []),
> default, nothing)"
> />
>
> or like this:
>
> <input type="checkbox" name="toppings:list" value="Pepperoni"
> checked="checked"
> tal:attributes="checked python:('Pepperoni' in
> request.get('toppings',[])) and
> default or nothing" />
Yeah. These are nicer. I got my version long ago during discussions before
ZPT was included in Zope.
So, my select/option and radio examples without needing the special behavior
would look like this:
<select name="question_type" id="question_type">
<option value="Text" tal:attributes="selected
python:request.get('question_type', None) == 'Text' and 'selected' or
nothing">Text</option>
...
</select>
...and...
<input type="radio" name="required" value="1" tal:attributes="checked
python:request.get('required', None) == '1' and 'checked' or nothing" /> Yes
<input type="radio" name="required" value="0" tal:attributes="checked
python:request.get('required', None) == '0' and 'checked' or nothing"/> No
I don't know if any graphical editors will have a problem with multiple
inputs having the checked/selected attribute or not, so I chose the string
'selected' instead of default.
Did I miss anything? Is there an advantage or disadvantage of using
"and...or" instead of test()?
_______________________
Ron Bickers
Logic Etc, Inc.
More information about the Zope
mailing list