This project is archived and is in readonly mode.

#1432 incomplete

check_box_tag should behave like radio_button_tag

Reported by qoobaa | November 22nd, 2008 @ 01:11 PM | in 3.x

This patch fixes standard behaviour of check_box_tag:

# check_box_tag 'eula', 'accepted', false, :disabled => true
# #=> <input disabled="disabled" id="eula" name="eula" type="checkbox" value="accepted" />


# check_box_tag 'eula', 'accepted', false, :disabled => true
# #=> <input disabled="disabled" id="eula_accepted" name="eula" type="checkbox" value="accepted" />

Now it's possible to use check_box_tag with the same name multiple times. Additionally I've cleaned radio_button_tag to use sanitize_to_id.

Comments and changes to this ticket

  • Jacek Becela

    Jacek Becela November 24th, 2008 @ 07:06 PM

    • Tag changed from actionpack, action_view, edge, forms to actionpack, action_view, edge, forms, patch, tested
    1. Take a look at this (typical habtm scenario with checkboxes):


    check_box_tag "user[neighborhood_ids][]",, current_user.neighborhoods.include?(neighborhood), :id => "user_neighborhood_id_#{}"

    With patch applied (notice I didn't need to specify my custom :id):

    check_box_tag "user[neighborhood_ids][]",, current_user.neighborhoods.include?(neighborhood)
  • Jacek Becela

    Jacek Becela November 24th, 2008 @ 07:08 PM

    A second time today my +1 gets eaten. I forgot not to begin a sentence with a plus :)

  • Frederick Cheung

    Frederick Cheung December 15th, 2008 @ 11:12 PM

    It would however break backwards compatibility (and in a way that is unlike to be covered by your application's tests), eg if you had

    <%= check_box_tag 'foo', '1' %>
    <%= observe_field 'foo' %>

    Although the simplification of the example in the first comment is nice.

  • Pratik

    Pratik March 8th, 2009 @ 01:06 PM

    • Assigned user set to “Pratik”
    • State changed from “new” to “incomplete”

    I think this change needs to be discussed in the mailing list first. Also, it's probably better to commit it after 2.3 is released/branched.

    Thanks !

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Ryan Bigg

    Ryan Bigg November 8th, 2010 @ 01:53 AM

    • Tag cleared.

    Automatic cleanup of spam.

  • bingbing

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>