Module: Eac::CommonFormHelper

Defined in:
lib/eac/common_form_helper.rb,
lib/eac/common_form_helper/form_builder.rb,
lib/eac/common_form_helper/form_builder/date_field.rb,
lib/eac/common_form_helper/form_builder/fields_for.rb,
lib/eac/common_form_helper/form_builder/file_field.rb,
lib/eac/common_form_helper/form_builder/time_field.rb,
lib/eac/common_form_helper/form_builder/select_field.rb,
lib/eac/common_form_helper/form_builder/currency_field.rb,
lib/eac/common_form_helper/form_builder/year_month_field.rb,
lib/eac/common_form_helper/form_builder/common_text_fields.rb,
lib/eac/common_form_helper/form_builder/radio_select_field.rb,
lib/eac/common_form_helper/form_builder/association_select_field.rb,
lib/eac/common_form_helper/form_builder/searchable_association_field.rb

Defined Under Namespace

Classes: FormBuilder

Instance Method Summary collapse

Instance Method Details

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



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/eac/common_form_helper.rb', line 3

def common_form(model_instance, options = {}, &block)
  submit_label = options.delete(:submit_label)
  options[:html] ||= {}
  options[:html][:class] = 'CommonFormHelper'
  form_for(model_instance, options) do |form|
    fb = FormBuilder.new(form, self)
    errors(model_instance) <<
      capture(fb, &block) <<
      errors_not_showed(model_instance, fb.field_errors_showed) <<
      form.submit(submit_label, class: 'btn btn-primary')
  end
end