Sha256: 2e271710f67657f37da0f4b7e7ca1bc224bb09ff8270d179cc057b578362ff02

Contents?: true

Size: 783 Bytes

Versions: 8

Compression:

Stored size: 783 Bytes

Contents

module Avo
  module Fields
    class SelectField < Field
      def initialize(name, **args, &block)
        @defaults = {
          sortable: true,
          component: 'select-field',
        }

        super(name, **args, &block)

        @options = args[:options].present? ? args[:options] : {}
        @enum = args[:enum].present? ? args[:enum] : nil
        @display_value = args[:display_value].present? ? args[:display_value] : false
        @placeholder = args[:placeholder].present? ? args[:placeholder].to_s : 'Choose an option'
      end

      def hydrate_field(fields, model, resource, view)
        {
          options: @options,
          enum: @enum,
          display_value: @display_value,
          placeholder: @placeholder,
        }
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
avo-0.3.2 lib/avo/app/fields/select_field.rb
avo-0.3.1 lib/avo/app/fields/select_field.rb
avo-0.2.5 lib/avo/app/fields/select_field.rb
avo-0.2.4 lib/avo/app/fields/select_field.rb
avo-0.2.3 lib/avo/app/fields/select_field.rb
avo-0.2.2 lib/avo/app/fields/select_field.rb
avo-0.2.1 lib/avo/app/fields/select_field.rb
avo-0.2.0 lib/avo/app/fields/select_field.rb