[CentralOH] Radio buttons with Chameleon

Mark Erbaugh mark at microenh.com
Sun Jul 24 01:04:02 CEST 2011


I'm trying to design a HTML form using Chameleon. I want to have one of group of radio buttons selected based on the value of a form parameter.

I got something that seems to work but is awkward. Am I doing it right?

> <label>Relationship
>   <input type="radio" tal:attributes="checked contact.relations==-2 and 'yes' or None" name="relations" value="-2" />Very Poor
>   <input type="radio" tal:attributes="checked contact.relations==-1 and 'yes' or None" name="relations" value="-1" />Poor
>   <input type="radio" tal:attributes="checked contact.relations==0  and 'yes' or None" name="relations" value="0"  />Neutral
>   <input type="radio" tal:attributes="checked contact.relations==1  and 'yes' or None" name="relations" value="1"  />Good
>   <input type="radio" tal:attributes="checked contact.relations==2  and 'yes' or None" name="relations" value="2"  />Very Good
> </label>

The field contact.relationship contains an integer, -2 = 'Very Poor'  through +2 = 'Very Good'

Is there a way to generate this code using a tal:repeat instead?

Mark


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/centraloh/attachments/20110723/b067a13e/attachment.html>


More information about the CentralOH mailing list