Sha256: 453d61542702641e88d773085666ba6186ad6a7cc67e75928df478ea1cdb2942

Contents?: true

Size: 795 Bytes

Versions: 10

Compression:

Stored size: 795 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 : I18n.t('avo.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

10 entries across 10 versions & 1 rubygems

Version Path
avo-0.4.10 lib/avo/app/fields/select_field.rb
avo-0.4.9 lib/avo/app/fields/select_field.rb
avo-0.4.8 lib/avo/app/fields/select_field.rb
avo-0.4.7 lib/avo/app/fields/select_field.rb
avo-0.4.6 lib/avo/app/fields/select_field.rb
avo-0.4.5 lib/avo/app/fields/select_field.rb
avo-0.4.4 lib/avo/app/fields/select_field.rb
avo-0.4.3 lib/avo/app/fields/select_field.rb
avo-0.4.2 lib/avo/app/fields/select_field.rb
avo-0.4.1 lib/avo/app/fields/select_field.rb