Class: Alchemy::Admin::ElementSelect
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Alchemy::Admin::ElementSelect
- Defined in:
- app/components/alchemy/admin/element_select.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(elements, field_name: "element[name]") ⇒ ElementSelect
constructor
A new instance of ElementSelect.
Constructor Details
#initialize(elements, field_name: "element[name]") ⇒ ElementSelect
Returns a new instance of ElementSelect.
8 9 10 11 |
# File 'app/components/alchemy/admin/element_select.rb', line 8 def initialize(elements, field_name: "element[name]") @field_name = field_name @elements = elements end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
6 7 8 |
# File 'app/components/alchemy/admin/element_select.rb', line 6 def elements @elements end |
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
6 7 8 |
# File 'app/components/alchemy/admin/element_select.rb', line 6 def field_name @field_name end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'app/components/alchemy/admin/element_select.rb', line 13 def call text_field_tag(field_name, nil, { "data-options": .to_json, "data-placeholder": Alchemy.t(:select_element), is: "alchemy-element-select", autofocus: true, required: true, value: elements.many? ? nil : elements.first&.name }) end |