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.

InstanceTag to_label_tag id attribute

#2660

InstanceTag method to_label_tag produces the wrong for attribute when an id options is given.

The solution is to add the marked line in to_label_tag:

name_and_id = options.dup
+ name_and_id["id"] = name_and_id.delete("for")

The attachment adds this line and a test (could not run the test, cause i get a Debugger:Module not found error, its the first time i did this, so i dont know how to fix this)

Reported by Di Marcello · May 17th, 2009 @ 02:24 PM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Di Marcello
    Di Marcello

    somehow something went wrong in my ticket body.
    it should look like this:

    name_and_id = options.dup
    + name_and_id["id"] = name_and_id.delete("for")

    May 17th, 2009 @ 02:25 PM

  2. Di Marcello
    Di Marcello

    damnit!!!! my lines get messed up.
    the plus sign was the mark. So the line I added was only:

    name_and_id["id"] = name_and_id.delete("for")
    

    May 17th, 2009 @ 02:28 PM

  3. Di Marcello
    Di Marcello

    Why doesnt anyone picks this up?
    Did i do something wrong? it isnt such a big fix

    June 3rd, 2009 @ 11:49 AM

  4. Matt Jones
    Matt Jones

    The diff you've provided doesn't make sense against 2-3-stable, and the test doesn't appear likely to fail there either. What version of Rails did you encounter this problem on?

    June 8th, 2009 @ 09:46 PM

  5. Di Marcello
    Di Marcello

    on rails 2.3.2 the github master branche at the time of posting

    June 19th, 2009 @ 01:17 AM

  6. Matt Duncan
    Matt Duncan
    • Tag changed from actionpack, actionview, form_helper, instance_tag, label, to_label_tag to actionpack, actionview, bugmash, form_helper, instance_tag, label, to_label_tag

    Patch didn't apply cleanly for me so I re-created it and tweaked the tests for better coverage.

    I've attached a patch.

    August 8th, 2009 @ 04:52 PM

  7. Adam Keys
    Adam Keys

    I've verified this applies cleanly to 2-3-stable. Test coverage looks good. +1

    August 8th, 2009 @ 05:26 PM

  8. Josh Nichols
    Josh Nichols
    • Tag changed from actionpack, actionview, bugmash, form_helper, instance_tag, label, to_label_tag to actionpack, actionview, bugmash, form_helper, instance_tag, label, to_label_tag, verified

    It's reasonable enough to want to add an ID to a label, so +1.

    Verified Matt's patch applies to 2-3-stable, and works as advertised.

    August 9th, 2009 @ 08:48 PM

  9. Josh Nichols
    Josh Nichols

    Also verified it applies and works on master.

    August 9th, 2009 @ 08:49 PM

  10. Elad Meidar
    Elad Meidar

    +1 verified, +1 patch applies on 2-3-stable and master, tests pass on both.

    i can think of several cases where i'd like to have id on a label.

    August 9th, 2009 @ 09:36 PM

  11. Tristan Dunn
    Tristan Dunn

    +1

    Verified the patch applies to master and 2-3-stable cleanly with passing tests.

    August 9th, 2009 @ 11:46 PM

  12. Repository
  13. Repository
  14. José Valim
    José Valim
    • State changed from new to resolved
    • Tag changed from actionpack, actionview, bugmash, form_helper, instance_tag, label, to_label_tag, verified to actionpack, actionview, form_helper, instance_tag, label, to_label_tag, verified

    August 9th, 2009 @ 11:58 PM