Improve the presentation of the error messages when attempting to create a new action with invalid data. Thanks to James Kebinger for his patch. Fixes #522.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@553 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-06-08 04:17:37 +00:00
parent 4160cf0ab3
commit c93bd40515
5 changed files with 8 additions and 5 deletions

View file

@ -25,7 +25,7 @@
:url => todos_path, :method => :post,
:html=> { :id=>'todo-form-new-action', :name=>'todo', :class => 'inline-form' }) do -%>
<div id="status"><%= error_messages_for("item") %></div>
<div id="status"><%= error_messages_for("item", :object_name => 'action') %></div>
<label for="todo_description">Description</label>
<%= text_field( "todo", "description", "size" => 30, "tabindex" => 1) %>

View file

@ -1,4 +1,4 @@
<div id="error_status"><%= error_messages_for("todo") %></div>
<div id="error_status"><%= error_messages_for("todo", :object_name => 'action') %></div>
<%= hidden_field( "todo", "id" ) %>
<%= source_view_tag( @source_view ) %>

View file

@ -21,5 +21,5 @@ if @saved
end
else
page.show 'status'
page.replace_html 'status', "#{error_messages_for('todo')}"
page.replace_html 'status', "#{error_messages_for('todo', :object_name => 'action')}"
end

View file

@ -25,5 +25,5 @@ if @saved
page.redirect_to project_path(@todo.project_id)
end
else
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@todo.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @todo.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation")
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@todo.errors.count, "error")} prohibited this action from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @todo.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation")
end

View file

@ -794,8 +794,9 @@ div.message {
color: #fff;
}
#errorExplanation p {
#errorExplanation > p {
color: #333;
margin-top: 5px;
margin-bottom: 0;
padding: 5px;
}
@ -804,6 +805,8 @@ div.message {
font-size: 1em;
list-style-type: disc;
list-style-position: inside;
margin-left:7px;
color: #333;
}
ul#prefs {list-style-type: disc; margin-left: 15px;}