2020-08-10 14:45:17 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-08-03 20:13:53 +00:00
|
|
|
# Adaptar la renderización de campos con error de Rails para que sea
|
|
|
|
# compatible con Bootstrap4. La forma actual rompe los inputs
|
|
|
|
# personalizados.
|
|
|
|
ActionView::Base.field_error_proc = proc do |html_tag, _|
|
2020-08-07 14:15:06 +00:00
|
|
|
return unless html_tag
|
|
|
|
|
2020-08-03 20:13:53 +00:00
|
|
|
html = Nokogiri::HTML::DocumentFragment.parse html_tag
|
2020-08-10 14:45:17 +00:00
|
|
|
html&.children&.first&.attributes&.dig('class')&.value += ' is-invalid'
|
2020-08-03 20:13:53 +00:00
|
|
|
|
2020-08-10 14:45:17 +00:00
|
|
|
html&.to_s&.html_safe || html_tag
|
2020-08-03 20:13:53 +00:00
|
|
|
end
|