def semantic_errors(*args)
html_options = args.extract_options!
args = args - [:base]
full_errors = args.inject([]) do |array, method|
attribute = localized_string(method, method.to_sym, :label) || humanized_attribute_name(method)
errors = Array(@object.errors[method.to_sym]).to_sentence
errors.present? ? array << [attribute, errors].join(" ") : array ||= []
end
full_errors << @object.errors[:base]
full_errors.flatten!
full_errors.compact!
return nil if full_errors.blank?
if html_options[:class].blank?
html_options[:class] = "alert alert-danger"
else
html_options[:class] = "alert alert-danger " + html_options[:class]
end
template.content_tag(:div, html_options) do
template.content_tag(:a, "×".html_safe, :class => "close", "data-dismiss" => "alert") +
template.content_tag(:ul, {:class => "error-list"}) do
Formtastic::Util.html_safe(full_errors.map { |error| template.content_tag(:li, Formtastic::Util.html_safe(error)) }.join)
end
end
end