Show form errors

This commit is contained in:
sto 2025-03-21 19:49:37 +01:00
parent ea7cdcf608
commit 15e2493f87
2 changed files with 18 additions and 1 deletions

View File

@ -1,3 +1,7 @@
// Sassy
@import "bootstrap";
@import "bootstrap";
.error-message {
color: var(--bs-danger)
}

View File

@ -0,0 +1,13 @@
ActionView::Base.field_error_proc = proc do |html_tag, instance|
if html_tag.include? "<label"
appended_html = ""
if instance.error_message.is_a?(Array)
appended_html = "<div class='error-message form-text'>#{instance.error_message.map(&:humanize).uniq.join(", ")}</div>"
else
appended_html = "<div class='error-message form-text'>#{instance.error_message.humanize}</div>"
end
html_tag + appended_html.html_safe
else
html_tag
end
end