Is there any way to show errors not on top of form page, but next to field, that fired an error?
initializers/my_custom_error_messages.rb
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
errors = Array(instance.error_message).join(',')
%(#{html_tag}<span class="validation-error"> #{errors}</span>).html_safe
end
update:
without label
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
errors = Array(instance.error_message).join(',')
if html_tag =~ /^<label/
html_tag
else
%(#{html_tag}<span class="validation-error"> #{errors}</span>).html_safe
end
end
ref: rails guide
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With