module Formize module Helpers module FormHelper # Code picked from Justin French's formtastic gem FIELD_ERROR_PROC = proc do |html_tag, instance_tag| # :nodoc: html_tag end def with_custom_field_error_proc(&block) # :nodoc: default_field_error_proc = ::ActionView::Base.field_error_proc ::ActionView::Base.field_error_proc = FIELD_ERROR_PROC yield ensure ::ActionView::Base.field_error_proc = default_field_error_proc end # Generates a form with all its fields as defined in controller. # If no name is given, it uses the name of the controller to find the corresponding model def formize_form(*args) name, options = nil, {} name = args[0] if args[0].is_a? Symbol options = args[-1] if args[-1].is_a? Hash self.send("_#{options[:controller]||self.controller_name}_#{__method__}_#{name||self.controller_name}_tag") end # Generates all the fields as defined in controller with the