Sha256: 3aee39fece5fec5f3302c141f69b6e4a6efade414de45b650c49a005a1e8a83a

Contents?: true

Size: 999 Bytes

Versions: 32

Compression:

Stored size: 999 Bytes

Contents

# frozen_string_literal: true

module Phlexi
  module Form
    module Components
      class Textarea < Base
        include Concerns::HandlesInput

        def view_template
          textarea(**attributes) { field.dom.value }
        end

        protected

        def build_attributes
          super

          build_textarea_attributes
        end

        def build_textarea_attributes
          attributes[:placeholder] = attributes.fetch(:placeholder, field.placeholder)
          attributes[:autofocus] = attributes.fetch(:autofocus, field.focused?)
          attributes[:minlength] = attributes.fetch(:minlength, field.minlength)
          attributes[:maxlength] = attributes.fetch(:maxlength, field.maxlength)
          attributes[:readonly] = attributes.fetch(:readonly, field.readonly?)
          attributes[:required] = attributes.fetch(:required, field.required?)
          attributes[:disabled] = attributes.fetch(:disabled, field.disabled?)
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
phlexi-form-0.5.1 lib/phlexi/form/components/textarea.rb
phlexi-form-0.5.0 lib/phlexi/form/components/textarea.rb
phlexi-form-0.4.8 lib/phlexi/form/components/textarea.rb
phlexi-form-0.4.7 lib/phlexi/form/components/textarea.rb
phlexi-form-0.4.6 lib/phlexi/form/components/textarea.rb
phlexi-form-0.4.5 lib/phlexi/form/components/textarea.rb
phlexi-form-0.4.4 lib/phlexi/form/components/textarea.rb
phlexi-form-0.4.3 lib/phlexi/form/components/textarea.rb
phlexi-form-0.4.2 lib/phlexi/form/components/textarea.rb
phlexi-form-0.4.1 lib/phlexi/form/components/textarea.rb
phlexi-form-0.4.0 lib/phlexi/form/components/textarea.rb
phlexi-form-0.3.0 lib/phlexi/form/components/textarea.rb