summaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-26 18:07:13 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-26 18:07:13 +0000
commit7c568cccafeb2f1577349419f758478362bf3c97 (patch)
tree41ebbb213451ca2bda816bd21bc90a77c8cfad05 /app/helpers
parent9c264a7e66cbc64251e48a89eb8a0c37e556e491 (diff)
downloadredmine-7c568cccafeb2f1577349419f758478362bf3c97.tar.gz
redmine-7c568cccafeb2f1577349419f758478362bf3c97.zip
Adds a helper for displaying validation error messages.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9017 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 175fb5109..313b0f933 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -945,6 +945,20 @@ module ApplicationHelper
remote_form_for(*args, &proc)
end
+ def error_messages_for(*objects)
+ html = ""
+ objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact
+ errors = objects.map {|o| o.errors.full_messages}.flatten
+ if errors.any?
+ html << "<div id='errorExplanation'><ul>\n"
+ errors.each do |error|
+ html << "<li>#{h error}</li>\n"
+ end
+ html << "</ul></div>\n"
+ end
+ html.html_safe
+ end
+
def back_url_hidden_field_tag
back_url = params[:back_url] || request.env['HTTP_REFERER']
back_url = CGI.unescape(back_url.to_s)