This project is archived and is in readonly mode.

id for radio_button behavior
Reported by Nobuhiro IMAI | July 22nd, 2009 @ 05:39 AM | in 2.3.4
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,
Comments and changes to this ticket
- 
         José Valim July 23rd, 2009 @ 11:08 PM- Assigned user set to Michael Koziarski
 Here is a patch to fix it. 
- 
         José Valim July 23rd, 2009 @ 11:10 PMHere is a pastie, since Lighthouse and S3 are not friends yet. 
- 
            
         Nobuhiro IMAI July 24th, 2009 @ 08:44 AM- 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! 
- 
         José Valim August 8th, 2009 @ 11:42 AM- Tag changed from 2.3.3, action_view, form_helper, patch to 2.3.3, action_view, bugmash, form_helper, patch
 
- 
         Rizwan Reza August 8th, 2009 @ 12:59 PMverified +1 This patch works in master and 2-3-stable branches. Both of those branches are encountering the same problem unless it's intentional. 
- 
         
- 
            
         Matt Duncan August 8th, 2009 @ 03:09 PMverified +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. 
- 
            
         Josh Nichols August 10th, 2009 @ 03:41 AMVerified 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. 
- 
         Jeremy Kemper August 10th, 2009 @ 06:16 AM- 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
 
- 
         Repository August 10th, 2009 @ 06:16 AM(from [e972acc0d7b63e5ce15bed69f41214fe741a7c9c]) Allow radio buttons to work with booleans. [#2937 state:committed] Signed-off-by: Pratik Naik pratiknaik@gmail.com 
 http://github.com/rails/rails/commit/e972acc0d7b63e5ce15bed69f41214...
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 
         2937 
          id for radio_button behavior
        [#2937 state:committed] 2937 
          id for radio_button behavior
        [#2937 state:committed]
- 
         4862 
          radio_button can generate duplicate id attributes (invalid HTML)
        Possibly related to #2937. 4862 
          radio_button can generate duplicate id attributes (invalid HTML)
        Possibly related to #2937.
- 
         2392 
          to_radio_button_tag ignores :index options partially
        Actually #1993 was already applied and introduced this
bu... 2392 
          to_radio_button_tag ignores :index options partially
        Actually #1993 was already applied and introduced this
bu...
 Jeremy Kemper
      Jeremy Kemper
 José Valim
      José Valim
 Matt Duncan
      Matt Duncan
 Michael Koziarski
      Michael Koziarski
 Nobuhiro IMAI
      Nobuhiro IMAI