Class: SymbolizedInput
- Inherits:
-
SimpleForm::Inputs::Base
- Object
- SimpleForm::Inputs::Base
- SymbolizedInput
- Defined in:
- app/inputs/symbolized_input.rb
Overview
SimpleForm input wrapper: symbolized.
Direct Known Subclasses
Instance Method Summary collapse
- #input(_wrapper_options) ⇒ Object
- #input_html_classes ⇒ Object
- #render_field ⇒ Object
- #span_symbol(option_key = :symbol) ⇒ Object
Instance Method Details
#input(_wrapper_options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/inputs/symbolized_input.rb', line 4 def input() group_classes = ['input-group'] extra_group_class = [:input_group_class] || [:input_group_class] group_classes << extra_group_class if extra_group_class template.content_tag(:div, class: group_classes.compact.join(' ')) do if [:left_symbol] || [:right_symbol] template.concat span_symbol(:left_symbol) if [:left_symbol] template.concat render_field template.concat span_symbol(:right_symbol) if [:right_symbol] elsif [:position] == :right template.concat render_field template.concat span_symbol else template.concat span_symbol template.concat render_field end end end |
#input_html_classes ⇒ Object
23 24 25 |
# File 'app/inputs/symbolized_input.rb', line 23 def input_html_classes (super || []).push('form-control').uniq end |
#render_field ⇒ Object
32 33 34 |
# File 'app/inputs/symbolized_input.rb', line 32 def render_field @builder.input_field(attribute_name, ) end |
#span_symbol(option_key = :symbol) ⇒ Object
27 28 29 30 |
# File 'app/inputs/symbolized_input.rb', line 27 def span_symbol(option_key = :symbol) symbol = [option_key] || [option_key] || '?' template.content_tag(:span, symbol, class: 'input-group-text') end |