Sha256: 7bb4dd20c9a9327e2dc0a3dab0e098a4afa18b1ed9edea6f6b32f69be1eb68f8

Contents?: true

Size: 1.23 KB

Versions: 20

Compression:

Stored size: 1.23 KB

Contents

module Bhf::ActionView
  module FormOptions
    
    def option_groups_from_collection_for_select_with_html_attrs(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key, html_attrs)
      collection.map do |group|
        option_tags = options_from_collection_for_select_with_html_attrs(
          group.send(group_method), option_key_method, option_value_method, selected_key, html_attrs)

        content_tag(:optgroup, option_tags, label: group.send(group_label_method))
      end.join.html_safe
    end
    
    def options_from_collection_for_select_with_html_attrs(collection, value_method, text_method, selected, html_attrs)
      options = collection.map do |element|
        [
          value_for_collection(element, text_method), value_for_collection(element, value_method), option_html_attributes(element), 
          html_attrs.call(element)
        ]
      end
      selected, disabled = extract_selected_and_disabled(selected)
      select_deselect = {
        selected: extract_values_from_collection(collection, value_method, selected),
        disabled: extract_values_from_collection(collection, value_method, disabled)
      }
  
      options_for_select(options, select_deselect)
    end

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bhf-0.10.12 lib/bhf/action_view/form_options.rb
bhf-0.10.11 lib/bhf/action_view/form_options.rb
bhf-0.10.10 lib/bhf/action_view/form_options.rb
bhf-0.10.9 lib/bhf/action_view/form_options.rb
bhf-0.9.9 lib/bhf/action_view/form_options.rb
bhf-0.9.8 lib/bhf/action_view/form_options.rb
bhf-0.9.7 lib/bhf/action_view/form_options.rb
bhf-0.9.6 lib/bhf/action_view/form_options.rb
bhf-0.9.5 lib/bhf/action_view/form_options.rb
bhf-0.9.4 lib/bhf/action_view/form_options.rb
bhf-0.9.3 lib/bhf/action_view/form_options.rb
bhf-0.9.2 lib/bhf/action_view/form_options.rb
bhf-0.9.1 lib/bhf/action_view/form_options.rb
bhf-0.9.0 lib/bhf/action_view/form_options.rb
bhf-0.8.7 lib/bhf/action_view/form_options.rb
bhf-0.8.6 lib/bhf/action_view/form_options.rb
bhf-0.8.5 lib/bhf/action_view/form_options.rb
bhf-0.8.4 lib/bhf/action_view/form_options.rb
bhf-0.8.3 lib/bhf/action_view/form_options.rb
bhf-0.8.2 lib/bhf/action_view/form_options.rb