Sha256: 69cb7035b5c7d3ea5b388f2f878e5872701c4ac798b0308fef4e87dbe1d4c8ec

Contents?: true

Size: 661 Bytes

Versions: 3

Compression:

Stored size: 661 Bytes

Contents

# frozen_string_literal: true

module UiBibzInputs
  class StringInput < BaseInput
    enable :placeholder, :maxlength, :minlength, :pattern

    def input(wrapper_options = nil)
      unless string?
        input_html_classes.unshift('string')
        input_html_options[:type] ||= input_type if html5?
      end

      merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)

      @builder.text_field(attribute_name, merged_input_options)
    end

    def options
      super.merge({ value: @builder.object.send(attribute_name) || super[:value] })
    end

    private

    def string?
      input_type == :string
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ui_bibz-2.5.2 lib/ui_bibz/inputs/ui_bibz_inputs/string_input.rb
ui_bibz-2.5.1 lib/ui_bibz/inputs/ui_bibz_inputs/string_input.rb
ui_bibz-2.5.0 lib/ui_bibz/inputs/ui_bibz_inputs/string_input.rb