Hi,

I was wondering if anyone has written macros to assist in creating
HTML radio button sets.
I'd like to factor out all the information that's common to each
button, such as the NAME= and determining whether the CHECKED
attribute is present.

My current approach is along these lines:

[% radio-buttons-start name="FAVORITE_COLOR" value=user.favorite_color %]
What is your favorite color?
<ul>
<li>[% radio-button value="blue" %]
<li>[% radio-button value="green" %]
<li>...
</ul>
[% radio-buttons-end %]

And this would generate:

What is your favorite color:
<ul>
<li><INPUT NAME="FAVORITE_COLOR" TYPE="RADIO" VALUE="blue" ...CHECKED... >
<li><INPUT NAME="FAVORITE_COLOR" TYPE="RADIO" VALUE="green" ...CHECKED... >
</ul>

where ...CHECKED.... would be CHECKED if user.favorite_color was equal
to "blue" (or "green", etc.)

Comments? Already done? Is there a better way?

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to