Class: Effective::FormInputs::Select
- Inherits:
-
CollectionInput
- Object
- Effective::FormInput
- CollectionInput
- Effective::FormInputs::Select
- Defined in:
- app/models/effective/form_inputs/select.rb
Constant Summary
Constants inherited from Effective::FormInput
Effective::FormInput::BLANK, Effective::FormInput::EXCLUSIVE_CLASS_PREFIXES, Effective::FormInput::EXCLUSIVE_CLASS_SUFFIXES
Instance Attribute Summary
Attributes inherited from Effective::FormInput
Instance Method Summary collapse
Methods inherited from CollectionInput
#assign_options_collection!, #assign_options_collection_methods!, #collection_options, #custom?, #group_label_method, #group_method, #grouped?, #html_options, #initialize, #inline?, #label_method, #option_key_method, #option_value_method, #options_collection, #polymorphic?, #polymorphic_id_method, #polymorphic_id_value, #polymorphic_type_method, #polymorphic_type_value, #polymorphic_value, #value_method
Methods inherited from Effective::FormInput
#feedback_options, #hint_options, #initialize, #input_group_options, #label_options, #to_html, #wrapper_options
Constructor Details
This class inherits a constructor from Effective::FormInputs::CollectionInput
Instance Method Details
#build_input(&block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/effective/form_inputs/select.rb', line 9 def build_input(&block) html = if grouped? && polymorphic? @builder.grouped_collection_select(polymorphic_id_method, , group_method, group_label_method, option_key_method, option_value_method, , ) elsif grouped? @builder.grouped_collection_select(name, , group_method, group_label_method, option_key_method, option_value_method, , ) else @builder.collection_select(name, , value_method, label_method, , ) end if polymorphic? html += @builder.hidden_field(polymorphic_type_method, value: polymorphic_type_value) html += @builder.hidden_field(polymorphic_id_method, value: polymorphic_id_value) end if single_selected? html.gsub!('selected="selected"', '') if html.sub!('selected="selected"', "selected='selected'") end html.html_safe end |
#input_html_options ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/effective/form_inputs/select.rb', line 45 def classes = [ 'effective_select', 'form-control', ('polymorphic' if polymorphic?), ('grouped' if grouped?), ('hide-disabled' if hide_disabled?), ('tags-input' if ), ].compact.join(' ') { class: classes, multiple: (true if multiple?), include_blank: !multiple? }.compact end |
#input_js_options ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/effective/form_inputs/select.rb', line 30 def opts = { theme: 'bootstrap', minimumResultsForSearch: 6, width: 'style', placeholder: (.delete(:placeholder) || 'Please choose'), allowClear: !multiple?, tokenSeparators: ([',', ';', '\n', '\t'] if ), tags: (true if ), template: js_template, containerClass: ('hide-disabled' if hide_disabled?), dropdownClass: ('hide-disabled' if hide_disabled?), }.compact end |