5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-14 22:41:41 +00:00

no fallar si el tag no tiene class close #178

This commit is contained in:
f 2020-08-10 11:45:17 -03:00
parent 0fd76ebb04
commit 9a2f242e0d
2 changed files with 6 additions and 3 deletions

View file

@ -4,8 +4,9 @@
%p.lead= t('.errors.help')
%ul
- site.errors.messages.each_pair do |attr, error|
- attr = attr.to_s
- error.each do |e|
%li= link_to e, '#' + attr.to_s
%li= link_to t('activerecord.attributes.site.' + attr) + ' ' + e, '#' + attr
= form_for site, html: { class: form_class(site) } do |f|
- unless site.persisted?

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Adaptar la renderización de campos con error de Rails para que sea
# compatible con Bootstrap4. La forma actual rompe los inputs
# personalizados.
@ -5,7 +7,7 @@ ActionView::Base.field_error_proc = proc do |html_tag, _|
return unless html_tag
html = Nokogiri::HTML::DocumentFragment.parse html_tag
html.children.first.attributes['class'].value += ' is-invalid'
html&.children&.first&.attributes&.dig('class')&.value += ' is-invalid'
html.to_s.html_safe
html&.to_s&.html_safe || html_tag
end