7a2370f740
- Some views had a "Close" button. We've removed this, because we don't want users accidentally hiding the validation errors and not knowing what needs to be fixed. - Some views used `li`, some used `p`, some used `span`. We've standardized on `li`. - Some views only showed the first error. We've standardized on showing all of them. - Some views added an `#error_explanation` div, which we've made standard.
18 lines
490 B
Ruby
18 lines
490 B
Ruby
module FormHelper
|
|
def form_errors(model)
|
|
return unless model.errors.any?
|
|
|
|
pluralized = 'error'.pluralize(model.errors.count)
|
|
headline = "The form contains the following #{pluralized}:"
|
|
|
|
content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do
|
|
content_tag(:h4, headline) <<
|
|
content_tag(:ul) do
|
|
model.errors.full_messages.
|
|
map { |msg| content_tag(:li, msg) }.
|
|
join.
|
|
html_safe
|
|
end
|
|
end
|
|
end
|
|
end
|