Class: PhlexKit::NativeSelect
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::NativeSelect
- Defined in:
- app/components/phlex_kit/native_select/native_select.rb
Overview
Styled native
render PhlexKit::NativeSelect.new(name: "store_id") do
render PhlexKit::NativeSelectOption.new(value: "") { "All stores" }
render PhlexKit::NativeSelectGroup.new(label: "Live") do
render PhlexKit::NativeSelectOption.new(value: store.id) { store.name }
end
end
The yielded block is the
Constant Summary collapse
- SIZES =
size => extra class appended after the base select class (nil = default).
{ default: nil, sm: "sm" }.freeze
Instance Method Summary collapse
-
#initialize(size: :default, **attrs) ⇒ NativeSelect
constructor
A new instance of NativeSelect.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(size: :default, **attrs) ⇒ NativeSelect
Returns a new instance of NativeSelect.
24 25 26 27 |
# File 'app/components/phlex_kit/native_select/native_select.rb', line 24 def initialize(size: :default, **attrs) @size = size.to_sym @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/components/phlex_kit/native_select/native_select.rb', line 29 def view_template(&block) div(class: "pk-native-select") do select(**mix({ class: classes, data: { phlex_kit__form_field_target: "input", action: "change->phlex-kit--form-field#onChange invalid->phlex-kit--form-field#onInvalid" } }, @attrs), &block) render PhlexKit::NativeSelectIcon.new end end |