Sha256: 93d73536bd67984b82148fd408ff8c1000252731365491f29c74eda560c8350f

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

module TaoForm
  module Components
    module Select
      class MultipleResultComponent < TaoForm::Components::FieldComponent

        attr_reader :choices, :field_options

        def initialize view, builder, attribute_name, choices = nil, options = {}
          super view, builder, attribute_name, options
          @choices = choices

          init_field_options
        end

        def render &block
          if block_given?
            super
          elsif builder && attribute_name
            super {
              builder.select attribute_name, choices, field_options, {
                disabled: options[:disabled],
                multiple: true
              }
            }
          end
        end

        def self.component_name
          :multiple_select_result
        end

        private

        def init_field_options
          @field_options = options.extract!(
            :selected, :include_blank, :prompt, :include_hidden
          )
          @field_options[:disabled] = options.delete(:option_disabled) if options.has_key?(:option_disabled)
        end

        def default_options
          {class: 'tao-multiple-select-result select-result'}
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tao_form-1.0.0.beta.2 lib/tao_form/components/select/multiple_result_component.rb
tao_form-1.0.0.beta.1 lib/tao_form/components/select/multiple_result_component.rb