Return to Snippet

Revision: 5470
at March 10, 2008 22:55 by brianjlandau


Initial Code
module ActionView::Helpers::FormOptionsHelper
         
   def options_for_select_with_include_blank(container, selected = nil, include_blank = false)
      options = options_for_select_without_include_blank(container, selected)
      if include_blank
         options = "<option value=\"\">#{include_blank if include_blank.kind_of?(String)}</option>\n" + options
      end
      options
   end
   alias_method_chain :options_for_select, :include_blank
   
   def options_from_collection_for_select_with_include_blank(collection, value_method, text_method, selected = nil, include_blank = false)
      options = options_from_collection_for_select_without_include_blank(collection, value_method, text_method, selected)
      if include_blank
         options = "<option value=\"\">#{include_blank if include_blank.kind_of?(String)}</option>\n" + options
      end
      options
   end
   alias_method_chain :options_from_collection_for_select, :include_blank
   
end

Initial URL


Initial Description


Initial Title
Add Include Blank argument to Option Helpers

Initial Tags
form, rails, ruby

Initial Language
Ruby