Module: ActionView::Helpers::FormHelper
- Defined in:
- lib/bootstrap-form/form_helper.rb
Constant Summary collapse
- BOOTSTRAP_OPTIONS =
[:label, :hint].freeze
Instance Method Summary collapse
- #bootstrap_collection_select(object_name, method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
- #bootstrap_control_group_wrap(object_name, method, content, options = {}) ⇒ Object
- #bootstrap_email_field(object_name, method, options = {}) ⇒ Object
- #bootstrap_file_field(object_name, method, options = {}) ⇒ Object
- #bootstrap_password_field(object_name, method, options = {}) ⇒ Object
- #bootstrap_select(object_name, method, choices, options = {}, html_options = {}) ⇒ Object
- #bootstrap_text_area(object_name, method, options = {}) ⇒ Object
- #bootstrap_text_field(object_name, method, options = {}) ⇒ Object
- #inline_help_tag(messages) ⇒ Object
Instance Method Details
#bootstrap_collection_select(object_name, method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
22 23 24 25 |
# File 'lib/bootstrap-form/form_helper.rb', line 22 def bootstrap_collection_select(object_name, method, collection, value_method, text_method, = {}, = {}) [:class] = control_class([:class], [:object].errors[method]) bootstrap_control_group_wrap(object_name, method, collection_select(object_name, method, collection, value_method, text_method, (), ), ) end |
#bootstrap_control_group_wrap(object_name, method, content, options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/bootstrap-form/form_helper.rb', line 42 def bootstrap_control_group_wrap(object_name, method, content, ={}) = [:object].errors[method] error_block = inline_help_tag(.presence) hint_block = content_tag(:small, class: "text-muted") do [:hint] end if !.presence && [:hint] content_tag(:div, label(object_name, method, [:label], :class => 'control-label') + content + error_block + hint_block, class: 'form-group') end |
#bootstrap_email_field(object_name, method, options = {}) ⇒ Object
12 13 14 15 |
# File 'lib/bootstrap-form/form_helper.rb', line 12 def bootstrap_email_field(object_name, method, ={}) [:class] = control_class([:class], [:object].errors[method]) bootstrap_control_group_wrap(object_name, method, email_field(object_name, method, ()), ) end |
#bootstrap_file_field(object_name, method, options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/bootstrap-form/form_helper.rb', line 32 def bootstrap_file_field(object_name, method, ={}) [:class] = control_class([:class], [:object].errors[method], " form-control-file") bootstrap_control_group_wrap(object_name, method, file_field(object_name, method, ()), ) end |
#bootstrap_password_field(object_name, method, options = {}) ⇒ Object
17 18 19 20 |
# File 'lib/bootstrap-form/form_helper.rb', line 17 def bootstrap_password_field(object_name, method, ={}) [:class] = control_class([:class], [:object].errors[method]) bootstrap_control_group_wrap(object_name, method, password_field(object_name, method, ()), ) end |
#bootstrap_select(object_name, method, choices, options = {}, html_options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/bootstrap-form/form_helper.rb', line 27 def bootstrap_select(object_name, method, choices, ={}, ={}) [:class] = control_class([:class], [:object].errors[method]) bootstrap_control_group_wrap(object_name, method, select(object_name, method, choices, (), ), ) end |
#bootstrap_text_area(object_name, method, options = {}) ⇒ Object
37 38 39 40 |
# File 'lib/bootstrap-form/form_helper.rb', line 37 def bootstrap_text_area(object_name, method, ={}) [:class] = control_class([:class], [:object].errors[method]) bootstrap_control_group_wrap(object_name, method, text_area(object_name, method, ()), ) end |
#bootstrap_text_field(object_name, method, options = {}) ⇒ Object
7 8 9 10 |
# File 'lib/bootstrap-form/form_helper.rb', line 7 def bootstrap_text_field(object_name, method, ={}) [:class] = control_class([:class], [:object].errors[method]) bootstrap_control_group_wrap(object_name, method, text_field(object_name, method, ()), ) end |
#inline_help_tag(messages) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/bootstrap-form/form_helper.rb', line 54 def inline_help_tag() = Array.wrap() return '' if .empty? = ActiveSupport::SafeBuffer.new(" #{.to_sentence}") content_tag(:div, , class: 'invalid-feedback') end |