Sha256: e73fa6fe69da8a213748e726c5c87fb5a6bbe0467fb8750163138b2596f75781

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Phlexi
  module Form
    module Components
      class Textarea < Base
        def view_template
          textarea(**attributes) { field.dom.value }
        end

        protected

        def build_attributes
          super

          attributes[:id] = field.dom.id
          attributes[:name] = field.dom.name

          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

2 entries across 2 versions & 1 rubygems

Version Path
phlexi-form-0.3.0.rc1 lib/phlexi/form/components/textarea.rb
phlexi-form-0.2.0 lib/phlexi/form/components/textarea.rb