Module: Bh::FormBuilder::Comboboxes

Included in:
Bh::FormBuilder
Defined in:
lib/bh/form_builder/comboboxes.rb

Overview

The menu the bundle draws as a combobox: Bootstrap's toggle and a searchable menu built from a select it then hides, which stays the one thing the form submits.

Constant Summary collapse

WORDS =

The words the menu is read by, which belong to the gem rather than to a page.

i[all clear more no_results search].freeze

Instance Method Summary collapse

Instance Method Details

#combobox(method, choices = nil, options = {}, html_options = {}) ⇒ Object

method as a combobox over choices -- the select form.select would draw, carrying what the bundle needs to draw it as one instead. Every argument is that select's, and its own :prompt is what the toggle says before anything is picked. The words it is searched, cleared and emptied by are the gem's, in the reader's own language, and data given in html_options is kept over any of them.



16
17
18
19
20
21
# File 'lib/bh/form_builder/comboboxes.rb', line 16

def combobox(method, choices = nil, options = {}, html_options = {}, &)
  data = { controller: 'combobox', combobox_placeholder_value: options[:prompt],
           **bh_combobox_words, **html_options.fetch(:data, {}), }

  select method, choices, options, html_options.merge(data: data), &
end