Module: BootstrapForm::Helper
- Includes:
- BootstrapForm::Helpers::NestedForm
- Defined in:
- lib/bootstrap_form/helper.rb
Instance Method Summary collapse
- #bootstrap_form_for(object, options = {}, &block) ⇒ Object
- #bootstrap_form_tag(options = {}, &block) ⇒ Object
- #temporarily_disable_field_error_proc ⇒ Object
Instance Method Details
#bootstrap_form_for(object, options = {}, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bootstrap_form/helper.rb', line 7 def bootstrap_form_for(object, = {}, &block) .reverse_merge!({builder: BootstrapForm::FormBuilder}) [:html] ||= {} [:html][:role] ||= 'form' layout = case [:layout] when :inline "form-inline" when :horizontal "form-horizontal" end if layout [:html][:class] = [[:html][:class], layout].compact.join(" ") end temporarily_disable_field_error_proc do form_for(object, , &block) end end |
#bootstrap_form_tag(options = {}, &block) ⇒ Object
29 30 31 32 33 |
# File 'lib/bootstrap_form/helper.rb', line 29 def bootstrap_form_tag( = {}, &block) [:acts_like_form_tag] = true bootstrap_form_for("", , &block) end |
#temporarily_disable_field_error_proc ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/bootstrap_form/helper.rb', line 35 def temporarily_disable_field_error_proc original_proc = ActionView::Base.field_error_proc ActionView::Base.field_error_proc = proc { |input, instance| input } yield ensure ActionView::Base.field_error_proc = original_proc end |