diff --git a/app/models/site/forms.rb b/app/models/site/forms.rb index 9321dd6..29e54aa 100644 --- a/app/models/site/forms.rb +++ b/app/models/site/forms.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class Site + # Gestor de formularios del sitio module Forms # Esta clase es un Hash que es capaz de convertirse a strong params # según la definición del formulario en el sitio. @@ -21,12 +22,12 @@ class Site end def t(field) - self[field.to_s]['label'][I18n.locale.to_s] + dig(field.to_s, 'label', I18n.locale.to_s) end end # Campos del formulario que no son necesarios - EXCLUDED_FIELDS = %w[separator].freeze + EXCLUDED_FIELDS = %w[separator redirect].freeze # Campos que aceptan valores múltiples (checkboxes, input-map, # input-tag) ARRAY_FIELDS = %w[array].freeze diff --git a/app/views/contact_mailer/notify_usuaries.html.haml b/app/views/contact_mailer/notify_usuaries.html.haml index 792660b..bc3d5ef 100644 --- a/app/views/contact_mailer/notify_usuaries.html.haml +++ b/app/views/contact_mailer/notify_usuaries.html.haml @@ -1,4 +1,4 @@ - @params[:form].each do |field, value| %p - %strong= @params[:form_definition].t(field) + ':' + %strong= @params[:form_definition].t(field) || field + ':' = value diff --git a/app/views/contact_mailer/notify_usuaries.text.haml b/app/views/contact_mailer/notify_usuaries.text.haml index 1c440de..434a8d7 100644 --- a/app/views/contact_mailer/notify_usuaries.text.haml +++ b/app/views/contact_mailer/notify_usuaries.text.haml @@ -1,3 +1,3 @@ - @params[:form].each do |field, value| - = "#{@params[:form_definition].t(field)}: #{value}" + "#{@params[:form_definition].t(field) || field}: #{value}" \