Class: PredicateInput
- Inherits:
-
SimpleForm::Inputs::Base
- Object
- SimpleForm::Inputs::Base
- PredicateInput
- Defined in:
- app/inputs/predicate_input.rb
Overview
A compound input that renders a predicate dropdown (IN / NOT IN) alongside a
Tom Select multi-select. When the predicate changes the Stimulus controller
rewrites the element's name attribute so the correct scope key
({attr}_in or {attr}_not_in) is submitted with the form.
Usage:
f.input :state, as: :predicate,
collection: Customer.states_for_select,
label: 'Status'
Constant Summary collapse
- PREDICATES =
Predicates.
[ ['is any of', 'in'], ['is none of', 'not_in'] ].freeze
Instance Method Summary collapse
Instance Method Details
#input(_wrapper_options = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/inputs/predicate_input.rb', line 19 def input( = nil) template.content_tag( :div, class: 'input-group flex-nowrap w-100', data: { controller: 'predicate-select', 'predicate-select-base-name-value' => base_name } ) do template.concat predicate_dropdown template.concat values_select end end |