Changeset 1040

Show
Ignore:
Timestamp:
11/24/07 11:04:44 (11 months ago)
Author:
jimfree..@gmail.com
Message:

Patched options_from_collection_for_select so specs would pass. Still needs review tho.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/merb_helpers/lib/merb_helpers/form_helpers.rb

    r1037 r1040  
    441441                  ret << tag("option", '',     :value => '') if blank 
    442442            collection.each do |label, group| 
    443               ret << open_tag("optgroup", :label => label.to_s) + options_from_collection_for_select(group, attrs) + "</optgroup>" 
     443              ret << open_tag("optgroup", :label => label.to_s.humanize.titleize) + options_from_collection_for_select(group, attrs) + "</optgroup>" 
    444444            end 
    445445          end 
     
    448448          value_method   = attrs[:value_method] 
    449449          selected_value = attrs[:selected] 
    450           options_for_select( 
    451             collection.inject([]) { |options, object| options << [ object.send(value_method), object.send(text_method) ] }, 
     450           
     451          text_method ||= :to_s 
     452          value_method ||= text_method 
     453           
     454          options_for_select(collection.inject([]) { |options, object|  
     455              options << [ object.send(value_method), object.send(text_method) ] }, 
    452456            :selected => selected_value, :include_blank => blank, :prompt => prompt 
    453457          )