5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-03 06:26:08 +00:00
panel/config/initializers/bootstrap_field_with_errors.rb

12 lines
384 B
Ruby
Raw Normal View History

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
html.children.first.attributes['class'].value += ' is-invalid'
html.to_s.html_safe
end