[Zope] Why is it so hard to do simple things?
Harry Wilkinson
harryw@nipltd.com
Wed, 8 May 2002 11:51:04 +0100
On Wednesday 08 May 2002 5:41 am, Richard Jones wrote:
> On Wed, 8 May 2002 13:44, Chris McDonough wrote:
> > .. and a bonus alternate DTML implementation mirroring the Python one ..
> >
> > <dtml-let button_value="REQUEST.get('perm_or_temp', 'P')"
> > possible="{'P':'Persistent','T':'Temporary'}"
> > items="possible.items()">
> > <dtml-call "items.sort()">
> > <dtml-in items>
> > <dtml-let "checked = (_[sequence-key] == button_value) and '
> > CHECKED' or ''>
> > <INPUT TYPE='RADIO'
> > NAME=perm_or_temp
> > VALUE="<dtml-var sequence-key>"
> > <dtml-var checked>> <dtml-var sequence-item>
> > </dtml-let>
> > </dtml-in>
> > </dtml-let>
>
> How about a ZPT example to finish the set? I'd do it, but it's been too
> long since I was allowed to do ZPT :)
>
Lots of ways to do it in ZPT, again, but this is roughly how I'd do it off
the top of my head.
<tal:loop define="perm_or_temp python:request.get('perm_or_temp', 'P')"
repeat="radiodata python: ({'value':'P','label':'Permanent'},
{'value':'T','label':'Temporary'})">
<input type="radio" name="perm_or_temp"
tal:attributes="value radiodata/value;
checked python: perm_or_temp == radiodata/value">
<div tal:replace="radiodata/label">Permanent/Temporary</div>
</tal:loop>
Harry