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
-

kupa September 30th, 2008 @ 04:38 PM
- → Tag changed from form_helpers patch to form_helpers "merb-helpers" "merb-plugins" merb_helpers patch
I've updated also the newes merb-helpers which was recently merged to the merb-more.
git://github.com/pk/merb-more.git master
-
Michael Klishin (antares) October 5th, 2008 @ 09:27 PM
- → Milestone changed from to 1.0
- → State changed from new to open
- → Assigned user changed from to Michael Klishin (antares)
I applied it to head and 2 spec examples blow up with undefined method radio_button. Could you update it and attach a formatted patch (use git-format-patch)?
-

kupa October 8th, 2008 @ 06:53 PM
- → Tag changed from form_helpers "merb-helpers" "merb-plugins" merb_helpers patch to form_helpers merb-helpers merb-plugins merb_helpers patch
I did change the specs to match with head spec style. I hope I did the patches correctly following two patches should be my changes. I've updated my merb-more repo as well.
-

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 »
