Module: ActiveScaffold::Bridges::Chosen::Helpers::FormColumnHelpers

Defined in:
lib/active_scaffold/bridges/chosen/helpers.rb

Instance Method Summary collapse

Instance Method Details

#active_scaffold_input_chosen(column, html_options) ⇒ Object

requires RecordSelect plugin to be installed and configured.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/active_scaffold/bridges/chosen/helpers.rb', line 13

def active_scaffold_input_chosen(column, html_options)
  html_options[:class] << ' chosen'
  if column.association&.collection?
    record = html_options.delete(:object)
    associated_options, select_options = active_scaffold_plural_association_options(column, record)
    options = {selected: associated_options.collect(&:id), include_blank: as_(:_select_), object: record}

    html_options.update(multiple: true).update(column.options[:html_options] || {})
    options.update(column.options)
    active_scaffold_select_name_with_multiple html_options

    if (optgroup = options.delete(:optgroup))
      select(:record, column.name, active_scaffold_grouped_options(column, select_options, optgroup), options, html_options)
    else
      collection_select(:record, column.name, select_options, :id, column.options[:label_method] || :to_label, options, html_options)
    end
  else
    active_scaffold_input_select(column, html_options)
  end
end