Errors helper and field error proc

This commit is contained in:
2025-10-22 03:03:23 +03:00
parent ae1df5f608
commit ff8d520273
3 changed files with 41 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
# frozen_string_literal: true
module ErrorsHelper
# Rendering an error inside the field
#
# @param html_tag [ActiveSupport::SafeBuffer]
# @param instance [ActionView::Helpers::Tags::Base]
def field_error_helper(html_tag, instance)
return html_tag if instance.is_a?(ActionView::Helpers::Tags::Label) # Don't wrap labels
error_messages = instance.error_message
content_tag(:div, html_tag + content_tag(:div, error_messages.join('; '), class: 'error-text'),
class: 'field-with-errors')
end
end