Module: NdrUi::Bootstrap::InputGroupAddons
- Included in:
- NdrUi::BootstrapBuilder
- Defined in:
- app/builders/ndr_ui/bootstrap/input_group_addons.rb
Overview
Provides form builder method for Bootstrap input-group-addon
Instance Method Summary collapse
-
#text_field(method, options = {}) ⇒ Object
Identical signature to ActionView::Helpers::FormBuilder#text_field, but adds
:prepend
and:append
options to prepend and append text to the text_field.
Instance Method Details
#text_field(method, options = {}) ⇒ Object
Identical signature to ActionView::Helpers::FormBuilder#text_field, but adds :prepend
and :append
options to prepend and append text to the text_field. Would typically be used for units (centigrays, mm, etc). This implementation adds the associated bootstrap styling to the add-ons.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/builders/ndr_ui/bootstrap/input_group_addons.rb', line 9 def text_field(method, = {}) = .stringify_keys prepend = .delete('prepend') append = .delete('append') return super if prepend.blank? && append.blank? div_content = [] unless prepend.blank? div_content << @template.content_tag(:span, prepend, class: 'input-group-addon') end div_content << text_field_without_inline_errors(method, ) unless append.blank? div_content << @template.content_tag(:span, append, class: 'input-group-addon') end @template.content_tag(:div, @template.safe_join(div_content), class: 'input-group') end |