Module: Formula::FormHelper

Defined in:
lib/formula/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#formula_fields_for(record_or_name_or_array, *args, &block) ⇒ Object

Generates a wrapper around fields_for with :builder set to Formula::FormBuilder.

Supports:

  • f.formula_fields_for(@user.company)

Equivalent:

  • f.fields_for(@user.company, builder: Formula::FormulaFormBuilder))

Usage:

<% f.formula_fields_for(@user.company) do |company_f| %>
  <%= company_f.input :url %>
  <%= company_f.input :phone %>
<% end %>


43
44
45
46
47
# File 'lib/formula/form_helper.rb', line 43

def formula_fields_for(record_or_name_or_array, *args, &block)
  options = args.extract_options!
  options[:builder] ||= ::Formula::FormBuilder
  fields_for(record_or_name_or_array, *(args << options), &block)
end

#formula_form_for(record_or_name_or_array, *args, &proc) ⇒ Object

Generates a wrapper around form_for with :builder set to Formula::FormBuilder.

Supports:

  • formula_form_for(@user)

Equivalent:

  • form_for(@user, builder: Formula::FormBuilder))

Usage:

<% formula_form_for(@user) do |f| %>
  <%= f.input :email %>
  <%= f.input :password %>
<% end %>


21
22
23
24
25
# File 'lib/formula/form_helper.rb', line 21

def formula_form_for(record_or_name_or_array, *args, &proc)
  options = args.extract_options!
  options[:builder] ||= ::Formula::FormBuilder
  form_for(record_or_name_or_array, *(args << options), &proc)
end