Sha256: 491be385d7ba69bfefac0c69142096bb93036e93de2c5a2a1a1f9050a05d0d20

Contents?: true

Size: 790 Bytes

Versions: 3

Compression:

Stored size: 790 Bytes

Contents

module Trestle
  class Form
    module Fields
      class DatetimeSelect < Field
        attr_reader :html_options

        def initialize(builder, template, name, options={}, html_options={}, &block)
          super(builder, template, name, options, &block)

          @html_options = default_html_options.merge(html_options)
        end

        def field
          content_tag(:div, class: "datetime-select") do
            builder.raw_datetime_select(name, options, html_options, &block)
          end
        end

        def default_html_options
          Trestle::Options.new(class: ["form-select"], disabled: readonly?, data: { controller: "select" })
        end
      end
    end
  end
end

Trestle::Form::Builder.register(:datetime_select, Trestle::Form::Fields::DatetimeSelect)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trestle-0.10.0 lib/trestle/form/fields/datetime_select.rb
trestle-0.10.0.pre2 lib/trestle/form/fields/datetime_select.rb
trestle-0.10.0.pre lib/trestle/form/fields/datetime_select.rb