Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

check_box_tag should behave like radio_button_tag

#1432

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" />

to:


# 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.

Reported by qoobaa · November 22nd, 2008 @ 01:11 PM

State: incomplete
Milestone: 3.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Jacek Becela
    Jacek Becela
    • 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):

    Now:

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

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

    
    check_box_tag "user[neighborhood_ids][]", neighborhood.id, current_user.neighborhoods.include?(neighborhood)
    

    November 24th, 2008 @ 07:06 PM

  2. Jacek Becela
    Jacek Becela

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

    November 24th, 2008 @ 07:08 PM

  3. Frederick Cheung
    Frederick Cheung

    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.

    December 15th, 2008 @ 11:12 PM

  4. Pratik
    Pratik
    • 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 !

    March 8th, 2009 @ 01:06 PM

  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  6. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    November 8th, 2010 @ 01:53 AM

  7. bingbing