This project is archived and is in readonly mode.

#709 ✓wontfix
Jonathon Wolfe

Ability to skip html-escaping in options_for_select()

Reported by Jonathon Wolfe | July 26th, 2008 @ 01:57 AM | in 2.x

I need the ability to insert non-breaking spaces ( ) in option tags that are currently being generated with the collection_select helper. However, options_for_select() always html_escapes the text of an option tag (line 201 of rails/actionpack/lib/action_view/helpers/form_options_helper.rb).

It would be wonderful if one could pass an option that tells options_for_select to skip html_escaping of the option text so that we wouldn't have to build option tags by hand when html entities need to be included.

In investigating the issue, I noticed that Kevin Clark submitted a patch for this way back in 2005, but the ticket was closed as "wontfix". Looking at the comments on the ticket (, I think the ticket "wontfix" resolution was more due to misunderstanding rather than it not being a valid issue. Would a patch to the current rails codebase allowing similar flexibility meet the same fate?

Comments and changes to this ticket

  • Pratik

    Pratik July 26th, 2008 @ 03:17 PM

    • State changed from “new” to “incomplete”

    It sounds like a reasonable thing to me. Please submit a patch.

  • Pratik

    Pratik July 26th, 2008 @ 03:17 PM

    • Assigned user set to “Pratik”
  • Jonathon Wolfe

    Jonathon Wolfe October 13th, 2008 @ 07:32 PM

    Hey, I forgot about this ticket for a while, sorry.

    I did put together a changeset a while back that adds the ability to skip the html-escaping in options_for_select, but I actually don't think it should be applied -- the patch took more code than I had anticipated, and required changing the call signature of options_for_select, options_from_collection_for_select, and option_groups_from_collection_for_select in order for things to be consistent.

    I'd thought it would be a simple one-line change, and it would have been if these methods took an options hash rather than a host of separate params, but as it is, I think the patch would add more complexity than it's worth, and it's better to say you've got to build your option tags yourself if you want the contents to not be html-escaped.

  • Pratik

    Pratik October 13th, 2008 @ 10:45 PM

    • State changed from “incomplete” to “wontfix”

    Ok let's close this for now then.

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>

People watching this ticket