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.

id for radio_button behavior

#2937

Hello,

is the following behevior intentional?

Loading development environment (Rails 2.3.2)
>> irb helper
>> @foo = "foo"
>> puts(radio_button("foo", "hash", true))
<input id="foo_hash_true" name="foo[hash]" type="radio" value="true" />
                   ^^^^^
>> puts(radio_button("foo", "hash", false))
<input id="foo_hash_false" name="foo[hash]" type="radio" value="false" />
                   ^^^^^^

Loading development environment (Rails 2.3.3)
>> irb helper
>> @foo = "foo"
>> puts(radio_button("foo", "hash", true))
<input id="foo_hash_true" name="foo[hash]" type="radio" value="true" />
                   ^^^^^ same as 2.3.2
>> puts(radio_button("foo", "hash", false))
<input id="foo_hash" name="foo[hash]" type="radio" value="false" />
                   ? different from 2.3.2

Yes, I know that the 3rd argument should be string, and
this comes from around add_default_name_and_id_for_value.

Thanks,

Reported by Nobuhiro IMAI · July 22nd, 2009 @ 05:39 AM

State: committed
Milestone: 2.3.4
Assigned to: Michael Koziarski Michael Koziarski
Importance: Medium

Activity

  1. José Valim
    José Valim
    • Assigned user set to Michael Koziarski

    Here is a patch to fix it.

    July 23rd, 2009 @ 11:08 PM

  2. José Valim
    José Valim

    Here is a pastie, since Lighthouse and S3 are not friends yet.

    http://pastie.org/557013

    July 23rd, 2009 @ 11:10 PM

  3. Nobuhiro IMAI
    Nobuhiro IMAI
    • Tag changed from 2.3.3, action_view, form_helper to 2.3.3, action_view, form_helper, patch

    Hello,

    this patch works fine for me, thanks!

    July 24th, 2009 @ 08:44 AM

  4. José Valim
    José Valim
    • Tag changed from 2.3.3, action_view, form_helper, patch to 2.3.3, action_view, bugmash, form_helper, patch

    August 8th, 2009 @ 11:42 AM

  5. Rizwan Reza
    Rizwan Reza

    verified

    +1 This patch works in master and 2-3-stable branches. Both of those branches are encountering the same problem unless it's intentional.

    August 8th, 2009 @ 12:59 PM

  6. Rizwan Reza
  7. Matt Duncan
    Matt Duncan

    verified

    +1 works and all tests pass, based on the commit where it was added (http://github.com/rails/rails/commit/a14df8c9b26b489f1db8fba64c72da...) this behavior appears to be unintentional.

    August 8th, 2009 @ 03:09 PM

  8. Josh Nichols
    Josh Nichols

    Verified the patch applies to 2-3-stable, and returns the previous behavior.

    I'm kinda leaning towards -1, because I think the 2.3.3 behavior seems more correct to me. Most of the form helpers have ids like model_attribute, and 2.3.3 makes this consistent for radio buttons as well. I can't really think of a reason you'd want the id to have the current selectedness of a radio button.

    August 10th, 2009 @ 03:41 AM

  9. Jeremy Kemper
    Jeremy Kemper
    • Tag changed from 2.3.3, action_view, bugmash, form_helper, patch to 2.3.3, action_view, form_helper, patch
    • State changed from new to committed
    • Milestone changed from 2.x to 2.3.4

    August 10th, 2009 @ 06:16 AM

  10. Repository