Class: SymbolizedInput
- Inherits:
-
SimpleForm::Inputs::Base
- Object
- SimpleForm::Inputs::Base
- SymbolizedInput
- Defined in:
- app/inputs/symbolized_input.rb
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
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/inputs/symbolized_input.rb', line 2 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
21 22 23 |
# File 'app/inputs/symbolized_input.rb', line 21 def input_html_classes (super || []).push('form-control').uniq end |
#render_field ⇒ Object
30 31 32 |
# File 'app/inputs/symbolized_input.rb', line 30 def render_field @builder.input_field(attribute_name, ) end |
#span_symbol(option_key = :symbol) ⇒ Object
25 26 27 28 |
# File 'app/inputs/symbolized_input.rb', line 25 def span_symbol(option_key = :symbol) symbol = [option_key] || [option_key] || '?' template.content_tag(:span, symbol, class: 'input-group-text') end |