Sha256: 14f3a5ab6b2fafc51a5a5e4b9b4ea09f2ee9f0ffddc03a33a4521f4985882550

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

module TaoForm
  module Inputs
    class CollectionSelectInput < ::SimpleForm::Inputs::CollectionSelectInput

      def input(wrapper_options = nil)
        label_method, value_method = detect_collection_methods
        merged_html_options = merge_wrapper_options(input_html_options, wrapper_options)
        merged_component_options = component_options.merge(merged_html_options)

        template.send :tao_select, merged_component_options do
          @builder.collection_select(
            attribute_name, collection, value_method, label_method, field_options, {
              multiple: merged_component_options[:multiple],
              disabled: merged_component_options[:disabled]
            }
          )
        end
      end

      private

      def component_options
        @component_options ||= input_options.slice(:multiple, :remote, :max_list_size,
          :searchable_size, :clearable, :placeholder, :disabled, :option_disabled,
          :include_blank, :prompt)
      end

      def field_options
        @field_options ||= begin
          opts = input_options.slice(:selected, :option_disabled, :include_blank, :prompt)
          opts[:disabled] = opts.delete(:option_disabled)
          opts
        end
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tao_form-0.1.10 lib/tao_form/inputs/collection_select_input.rb
tao_form-0.1.9 lib/tao_form/inputs/collection_select_input.rb
tao_form-0.1.8 lib/tao_form/inputs/collection_select_input.rb
tao_form-0.1.7 lib/tao_form/inputs/collection_select_input.rb
tao_form-0.1.6 lib/tao_form/inputs/collection_select_input.rb
tao_form-0.1.5 lib/tao_form/inputs/collection_select_input.rb
tao_form-0.1.4 lib/tao_form/inputs/collection_select_input.rb