Module: Super::FormBuilderHelper

Defined in:
app/helpers/super/form_builder_helper.rb

Overview

These are form builder view helpers. They are similar to what Rails ships out of the box but adds some styling and functionality.

These helpers are available both in Super views and in your application's views.

Instance Method Summary collapse

Instance Method Details

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

Super's version of #form_for



11
12
13
14
15
16
17
18
19
# File 'app/helpers/super/form_builder_helper.rb', line 11

def super_form_for(record, options = {}, &block)
  original = ActionView::Base.field_error_proc
  ActionView::Base.field_error_proc = Form::Builder::FIELD_ERROR_PROC

  options[:builder] ||= Form::Builder
  return form_for(record, options, &block)
ensure
  ActionView::Base.field_error_proc = original
end

#super_form_with(**options, &block) ⇒ Object

Super's version of #form_with



22
23
24
25
26
27
28
29
30
# File 'app/helpers/super/form_builder_helper.rb', line 22

def super_form_with(**options, &block)
  original = ActionView::Base.field_error_proc
  ActionView::Base.field_error_proc = Form::Builder::FIELD_ERROR_PROC

  options[:builder] ||= Form::Builder
  return form_with(**options, &block)
ensure
  ActionView::Base.field_error_proc = original
end