Hello,
the CGI plugin with method radio_group can go something similar for you.
In template:
[% USE CGI %]
[% CGI.radio_group(
'-name' => 'FAVORITE_COLOR',
'-values' => ['blue','green',],
'-default' => 'blue',
).join("\n")
%]
produce
<label><input type="radio" name="FAVORITE_COLOR" value="blue"
checked="checked" />blue</label>
<label><input type="radio" name="FAVORITE_COLOR" value="green"
/>green</label>
advantage could be that it accepts an array, that could be easily
supplied from the application. It has more options that might help,
please see
http://search.cpan.org/~lds/CGI.pm-3.44/CGI.pm#CREATING_A_RADIO_BUTTON_GROUP
-- regards, Roman
E R napsal(a):
> 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
>
>
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates