Sha256: 42137f82f26200a2abb3c26b3c7613e060ca3ed98c0bddcd9ddee6179ca5ada8

Contents?: true

Size: 937 Bytes

Versions: 22

Compression:

Stored size: 937 Bytes

Contents

module ErrorMessagesHelper
  # Render error messages for the given objects. The :message and :header_message options are allowed.
  def error_messages_for(*objects)
    options = objects.extract_options!
    options[:header_message] ||= "Invalid Fields"
    options[:message] ||= "Correct the following errors and try again."
    messages = objects.compact.map { |o| o.errors.full_messages }.flatten
    unless messages.empty?
      content_tag(:div, :class => "error_messages") do
        list_items = messages.map { |msg| content_tag(:li, msg) }
        content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe)
      end
    end
  end

  module FormBuilderAdditions
    def error_messages(options = {})
      @template.error_messages_for(@object, options)
    end
  end
end

ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)

Version data entries

22 entries across 22 versions & 4 rubygems

Version Path
dust-cms-0.0.07 app/helpers/error_messages_helper.rb
dust-cms-0.0.06 app/helpers/error_messages_helper.rb
dust-cms-0.0.05 app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.9.0 integration/app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.8.0 integration/app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.7.5 integration/app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.7.4 integration/app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.7.3 integration/app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.7.2 integration/app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.7.1 integration/app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.7.0 integration/app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.6.6 integration/app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.6.5 integration/app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.6.4 integration/app/helpers/error_messages_helper.rb
rails3-jquery-autocomplete-0.6.3 integration/app/helpers/error_messages_helper.rb
dust-generators-0.0.1 lib/generators/dust/layout/templates/error_messages_helper.rb
rails3-jquery-autocomplete-0.6.2 integration/app/helpers/error_messages_helper.rb
nifty-generators-0.4.4 lib/generators/nifty/layout/templates/error_messages_helper.rb
nifty-generators-0.4.3 lib/generators/nifty/layout/templates/error_messages_helper.rb
rails3-jquery-autocomplete-0.6.1 integration/app/helpers/error_messages_helper.rb