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.

select_tag should allow :include_blank option

#1987

I think that "select_tag" should allow the :include_blank just like its object-related sibling "select" does. This makes it much easier to construct forms in a not strictly object-related context.

Examples:

<%= select_tag "country", %(<option value=""></option>) + options_for_select(Country.all) %>

would become

<%= select_tag "country", options_for_select(Country.all), :include_blank => true %>

<%= select_tag "country", %(<option value="">any</option>) + options_for_select(Country.all) %>

would become

<%= select_tag "country", options_for_select(Country.all), :include_blank => "any" %>

A patch including tests is attached.

Reported by Clemens Kofler · February 16th, 2009 @ 12:22 PM

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

Activity

  1. Jason Arora
    Jason Arora

    +1

    The patch and tests look good. A useful and logical addition.

    March 22nd, 2009 @ 11:52 PM

  2. seanliugm (at gmail)
  3. Rizwan Reza
    Rizwan Reza

    verified

    +1 This is a very useful addition. One that is manually tweaked as mentioned. The above patch didn't apply for 2-3-stable or master. So I have recreated with updated tests.

    August 8th, 2009 @ 03:31 PM

  4. Matt Duncan
    Matt Duncan

    +1 this is a very logical addition, Rizwan's patch applies cleanly with tests passing

    August 8th, 2009 @ 05:31 PM

  5. Repository
  6. Rizwan Reza
    Rizwan Reza

    Changed status to resolved.

    October 19th, 2009 @ 01:02 PM

  7. Tim Harvey
    Tim Harvey

    Please excuse me if there is an obvious answer to this question that I've missed...

    This is a terrific addition, but I don't find this patch in the latest 2.3.5 release. Did it somehow get passed over by mistake, or do patches take time to be incorporated? It would seem that the commit into the Rails repo would finalize the change and make it available upon the next release.

    Am I missing something?

    December 9th, 2009 @ 04:01 PM

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

    May 4th, 2010 @ 06:48 PM

  9. Rizwan Reza
    Rizwan Reza
    • State changed from new to resolved

    Tim, I think 2.3.x is being supported for bug fixes only... that's why.

    June 19th, 2010 @ 05:07 AM

  10. xhming
  11. xiannv