Class: Panda::Core::Admin::FormInputComponent
- Defined in:
- app/components/panda/core/admin/form_input_component.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#autocomplete ⇒ Object
readonly
Returns the value of attribute autocomplete.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#placeholder ⇒ Object
readonly
Returns the value of attribute placeholder.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #default_attrs ⇒ Object
-
#initialize(name: "", value: nil, placeholder: nil, autocomplete: nil, type: :text, required: false, disabled: false, **attrs) ⇒ FormInputComponent
constructor
A new instance of FormInputComponent.
Constructor Details
#initialize(name: "", value: nil, placeholder: nil, autocomplete: nil, type: :text, required: false, disabled: false, **attrs) ⇒ FormInputComponent
Returns a new instance of FormInputComponent.
7 8 9 10 11 12 13 14 15 16 |
# File 'app/components/panda/core/admin/form_input_component.rb', line 7 def initialize(name: "", value: nil, placeholder: nil, autocomplete: nil, type: :text, required: false, disabled: false, **attrs) @name = name @value = value @type = type @placeholder = placeholder @required = required @disabled = disabled @autocomplete = autocomplete super(**attrs) end |
Instance Attribute Details
#autocomplete ⇒ Object (readonly)
Returns the value of attribute autocomplete.
18 19 20 |
# File 'app/components/panda/core/admin/form_input_component.rb', line 18 def autocomplete @autocomplete end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
18 19 20 |
# File 'app/components/panda/core/admin/form_input_component.rb', line 18 def disabled @disabled end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'app/components/panda/core/admin/form_input_component.rb', line 18 def name @name end |
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
18 19 20 |
# File 'app/components/panda/core/admin/form_input_component.rb', line 18 def placeholder @placeholder end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
18 19 20 |
# File 'app/components/panda/core/admin/form_input_component.rb', line 18 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
18 19 20 |
# File 'app/components/panda/core/admin/form_input_component.rb', line 18 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
18 19 20 |
# File 'app/components/panda/core/admin/form_input_component.rb', line 18 def value @value end |
Instance Method Details
#default_attrs ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/panda/core/admin/form_input_component.rb', line 20 def default_attrs base_attrs = { type: @type.to_s, name: @name, id: @name.to_s.gsub(/[\[\]]/, "_").gsub("__", "_").chomp("_"), class: input_classes } base_attrs[:value] = @value if @value base_attrs[:placeholder] = @placeholder if @placeholder base_attrs[:required] = true if @required base_attrs[:disabled] = true if @disabled base_attrs[:autocomplete] = @autocomplete if @autocomplete base_attrs end |