Show form errors
This commit is contained in:
parent
ea7cdcf608
commit
15e2493f87
@ -1,3 +1,7 @@
|
||||
// Sassy
|
||||
|
||||
@import "bootstrap";
|
||||
@import "bootstrap";
|
||||
|
||||
.error-message {
|
||||
color: var(--bs-danger)
|
||||
}
|
13
config/initializers/form_errors.rb
Normal file
13
config/initializers/form_errors.rb
Normal 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
|
Loading…
x
Reference in New Issue
Block a user