Module: BootstrapForm::ActionViewExtensions::FormHelper
- Defined in:
- lib/bootstrap_form/action_view_extensions/form_helper.rb
Overview
This module creates BootstrapForm wrappers around the default form_with and form_for methods
Example:
bootstrap_form_for @user do |f|
f.text_field :name
end
Example:
bootstrap_form_with model: @user do |f|
f.text_field :name
end
Instance Method Summary collapse
- #bootstrap_fields(scope = nil, model: nil, **options, &block) ⇒ Object
- #bootstrap_fields_for(record_name, record_object = nil, options = {}, &block) ⇒ Object
- #bootstrap_form_for(record, options = {}, &block) ⇒ Object
- #bootstrap_form_tag(options = {}, &block) ⇒ Object
- #bootstrap_form_with(options = {}, &block) ⇒ Object
Instance Method Details
#bootstrap_fields(scope = nil, model: nil, **options, &block) ⇒ Object
47 48 49 50 |
# File 'lib/bootstrap_form/action_view_extensions/form_helper.rb', line 47 def bootstrap_fields(scope=nil, model: nil, **, &block) [:builder] = BootstrapForm::FormBuilder fields(scope, model: model, **, &block) end |
#bootstrap_fields_for(record_name, record_object = nil, options = {}, &block) ⇒ Object
42 43 44 45 |
# File 'lib/bootstrap_form/action_view_extensions/form_helper.rb', line 42 def bootstrap_fields_for(record_name, record_object=nil, ={}, &block) [:builder] = BootstrapForm::FormBuilder fields_for(record_name, record_object, , &block) end |
#bootstrap_form_for(record, options = {}, &block) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/bootstrap_form/action_view_extensions/form_helper.rb', line 20 def bootstrap_form_for(record, ={}, &block) .reverse_merge!(builder: BootstrapForm::FormBuilder) with_bootstrap_form_field_error_proc do form_for(record, , &block) end end |
#bootstrap_form_tag(options = {}, &block) ⇒ Object
36 37 38 39 40 |
# File 'lib/bootstrap_form/action_view_extensions/form_helper.rb', line 36 def bootstrap_form_tag(={}, &block) [:acts_like_form_tag] = true bootstrap_form_for("", , &block) end |
#bootstrap_form_with(options = {}, &block) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/bootstrap_form/action_view_extensions/form_helper.rb', line 28 def bootstrap_form_with(={}, &block) .reverse_merge!(builder: BootstrapForm::FormBuilder) with_bootstrap_form_field_error_proc do form_with(**, &block) end end |