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