Module: Bootstrap2FormBuilder::BootstrapFormHelper

Defined in:
lib/bootstrap2_form_builder.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_form_for(name, *args, &block) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bootstrap2_form_builder.rb', line 19

def bootstrap_form_for(name, *args, &block)
  options = args.extract_options!

  target = name
  if target.kind_of?(Array)
    target = name[1]
  end

  #Default form class to form-horizontal.
  form_html = {:html => {:class => Bootstrap2FormBuilder.default_form_layout}}

  #Work our default class back into the form options. Defer to whatever is passed in if present

  options.merge!(form_html) do |html_key, passed_in_html, default_html|
    passed_in_html.merge(default_html) do |key, oldval, newval|
      oldval
    end
  end

  partial_location = Bootstrap2FormBuilder.error_partial || "bootstrap2_form_builder/error_messages"

  render(partial_location, :target => target) + form_for(name, *(args << options.merge(:builder => Bootstrap2FormBuilder::FormBuilder)), &block)
end