Module: BootstrapForm::Helper

Defined in:
lib/bootstrap_form/helper.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_form_for(object, options = {}, &block) ⇒ Object


4
5
6
7
8
9
10
11
12
# File 'lib/bootstrap_form/helper.rb', line 4

def bootstrap_form_for(object, options = {}, &block)
  options.reverse_merge!({builder: BootstrapForm::FormBuilder})

  options = process_options(options)

  temporarily_disable_field_error_proc do
    form_for(object, options, &block)
  end
end

#bootstrap_form_tag(options = {}, &block) ⇒ Object


14
15
16
17
18
# File 'lib/bootstrap_form/helper.rb', line 14

def bootstrap_form_tag(options = {}, &block)
  options[:acts_like_form_tag] = true

  bootstrap_form_for("", options, &block)
end

#bootstrap_form_with(options = {}, &block) ⇒ Object


20
21
22
23
24
25
26
27
28
# File 'lib/bootstrap_form/helper.rb', line 20

def bootstrap_form_with(options = {}, &block)
  options.reverse_merge!(builder: BootstrapForm::FormBuilder)

  options = process_options(options)

  temporarily_disable_field_error_proc do
    form_with(options, &block)
  end
end

#temporarily_disable_field_error_procObject


45
46
47
48
49
50
51
# File 'lib/bootstrap_form/helper.rb', line 45

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