Sha256: ea91cf7bdf5c7982cfeb26c4442128e3b91c2cc7a7ef9151929bbd9ae5dd2de0
Contents?: true
Size: 574 Bytes
Versions: 9
Compression:
Stored size: 574 Bytes
Contents
# frozen_string_literal: true # Adds form__error class to the inputs after sending a form when errors ActionView::Base.field_error_proc = proc do |html_tag, _instance| include ActionView::Helpers::SanitizeHelper if html_tag =~ /<(input|textarea|select)/ error_class = 'form__error' doc = Nokogiri::XML(html_tag) doc.children.each do |field| next if field['type'] == 'hidden' next if field['class'] =~ /\berror\b/ field['class'] = "#{field['class']} #{error_class}".strip end sanitize doc.to_html else html_tag end end
Version data entries
9 entries across 9 versions & 1 rubygems