Files

Class/Module Index [+]

Quicksearch

ActionView::Helpers::FormOptionsHelper

Public Instance Methods

options_from_collection_for_select(collection, value_method, text_method, selected = nil) click to toggle source
# File lib/simple_form/action_view_extensions/builder.rb, line 290
def options_from_collection_for_select(collection, value_method, text_method, selected = nil)
  if value_method.respond_to?(:call) || text_method.respond_to?(:call)
    collection = collection.map do |item|
      value = value_for_collection(item, value_method)
      text  = value_for_collection(item, text_method)

      [value, text]
    end

    value_method, text_method = :first, :last
    selected = extract_selected_and_disabled_and_call_procs selected, collection
  end

  original_options_from_collection_for_select collection, value_method, text_method, selected
end
original_options_from_collection_for_select(collection, value_method, text_method, selected = nil) click to toggle source

Override Rails options_from_collection_for_select to handle lambdas/procs in text and value methods, so it works the same way as collection_radio_buttons and collection_check_boxes in SimpleForm. If none of text/value methods is a callable object, then it just delegates back to original collection select. FIXME: remove when support only Rails 4.0 forward

https://github.com/rails/rails/commit/9035324367526af0300477a58b6d3efc15d1a5a8

[Validate]

Generated with the Darkfish Rdoc Generator 2.