#178 open
kupa

Radio button checked enhancement

Reported by kupa | September 26th, 2008 @ 01:10 AM | in 1.0

I use bound radio buttons alone without group and I want to do something like:


<%= radio_button :sex, :value => 'M', :id => 'user_sex_M' %> <labe for="user_sex_M">Male</label>
<%= radio_button :sex, :value => 'F', :id => 'user_sex_F' %> <label for="user_sex_F">Female</label>

Which would result in following code when @user.sex == 'M'


<input type="radio" value="M" class="radio" checked="checked" name="user[sex]" id="user_sex_M"/> <label for="user_sex_M">Male</label>
<input type="radio" value="F" class="radio" name="user[sex]" id="user_sex_F"/> <label for="user_sex_F">Female</label>

Current helpers, can't set checked when using bound radio_button outside the group.

Also I'd like to be able to do this for the unbound radio_button:


<%= radio_button :sex, :value => 'M', :checked => (params['sex'] == 'M') %>

And get radio button with checked="checked" when expression is true and no checked="" when expression is false.

Patch: git://github.com/pk/merb-plugins.git master

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket