Module: SimpleForm::ActionViewExtensions::FormHelper

Defined in:
lib/simple_form/action_view_extensions/form_helper.rb

Overview

This module creates simple form wrappers around default form_for and fields_for.

Example:

simple_form_for @user do |f|
  f.input :name, :hint => 'My hint'
end

Constant Summary collapse

FIELD_ERROR_PROC =

Override the default ActiveRecordHelper behaviour of wrapping the input. This gets taken care of semantically by adding an error class to the wrapper tag containing the input.

proc do |html_tag, instance_tag|
  html_tag
end
@@default_field_error_proc =
nil

Instance Method Summary collapse

Instance Method Details

#with_custom_field_error_proc(&block) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/simple_form/action_view_extensions/form_helper.rb', line 24

def with_custom_field_error_proc(&block)
  @@default_field_error_proc = ::ActionView::Base.field_error_proc
  ::ActionView::Base.field_error_proc = FIELD_ERROR_PROC
  result = yield
  ::ActionView::Base.field_error_proc = @@default_field_error_proc
  result
end