diff --git a/app/models/field/complex_datation.rb b/app/models/field/complex_datation.rb index ced10b36f..162b7913e 100644 --- a/app/models/field/complex_datation.rb +++ b/app/models/field/complex_datation.rb @@ -283,7 +283,7 @@ def validate(record) return if value['to'].keys.all? { |key| value['to'][key].blank? || value['to'][key].nil? } && value['from'].keys.all? { |key| value['from'][key].blank? || value['from'][key].nil? } && !field.required if value['to'].keys.all? { |key| value['to'][key].blank? || value['to'][key].nil? } && value['from'].keys.all? { |key| value['from'][key].blank? || value['from'][key].nil? } && field.required - record.errors.add(:base, I18n.t('activerecord.errors.models.item.attributes.base.complex_datation_cant_be_blank')) + record.errors.add(attrib, I18n.t('activerecord.errors.models.item.attributes.base.cant_be_blank')) return end @@ -294,8 +294,8 @@ def validate(record) value['to'][char].blank? || value['to'][char].nil? || value['from'][char].blank? || value['from'][char].nil? end - record.errors.add(:base, I18n.t('activerecord.errors.models.item.attributes.base.wrong_complex_datation_format', field_format: field.format)) if invalid_format - record.errors.add(:base, :negative_dates) if !to_date_is_positive || !from_date_is_positive + record.errors.add(attrib, I18n.t('activerecord.errors.models.item.attributes.base.wrong_format', field_format: field.format)) if invalid_format + record.errors.add(attrib, :negative_dates) if !to_date_is_positive || !from_date_is_positive end end end diff --git a/app/models/field/date_time.rb b/app/models/field/date_time.rb index 9a1b9f45e..aaa47b98e 100644 --- a/app/models/field/date_time.rb +++ b/app/models/field/date_time.rb @@ -197,7 +197,7 @@ def validate(record) return if value.keys.all? { |key| value[key].blank? || value[key].nil? } && !field.required if value.keys.all? { |key| value[key].blank? || value[key].nil? } && field.required - record.errors.add(:base, I18n.t('activerecord.errors.models.item.attributes.base.date_time_cant_be_blank')) + record.errors.add(attrib, I18n.t('activerecord.errors.models.item.attributes.base.cant_be_blank')) return end @@ -205,7 +205,8 @@ def validate(record) value[char].blank? || value[char].nil? end - record.errors.add(:base, I18n.t('activerecord.errors.models.item.attributes.base.wrong_date_time_format', field_format: field.format)) if invalid_format + record.errors.add(attrib, I18n.t('activerecord.errors.models.item.attributes.base.wrong_format', field_format: field.format)) if invalid_format end end end + diff --git a/app/views/catalog_admin/items/_common_form_fields.html.erb b/app/views/catalog_admin/items/_common_form_fields.html.erb index 0c39e7436..07e35c800 100644 --- a/app/views/catalog_admin/items/_common_form_fields.html.erb +++ b/app/views/catalog_admin/items/_common_form_fields.html.erb @@ -13,6 +13,11 @@ :current_user => @current_user, :catalog => @catalog ) %> + <% if field.editor_component.present? %> + <% @item.errors.where(field.uuid).each do |error| %> +
<%= error.message %>
+ <% end %> + <% end %> <% end %>
diff --git a/config/locales/app/en.yml b/config/locales/app/en.yml index f4e703f97..7b40949fa 100644 --- a/config/locales/app/en.yml +++ b/config/locales/app/en.yml @@ -65,7 +65,9 @@ en: item: attributes: base: - negative_dates: "Negative dates must be entered with the option before Jesus Christ (if activated)" + cant_be_blank: "Doit etre rempli" + negative_dates: "Les dates négatives doivent être saisies avec l'option avant Jesus Christ (si activée)" + wrong_format: "Ne respecte pas le format %{field_format}" field/choice_set: attributes: choice_set_id: diff --git a/config/locales/app/fr.yml b/config/locales/app/fr.yml index 24214cc63..dd6836aac 100644 --- a/config/locales/app/fr.yml +++ b/config/locales/app/fr.yml @@ -67,11 +67,9 @@ fr: item: attributes: base: - complex_datation_cant_be_blank: "Le champ complexe datation doit etre rempli" - date_time_cant_be_blank: "Le champ date time doit etre rempli" + cant_be_blank: "Doit etre rempli" negative_dates: "Les dates négatives doivent être saisies avec l'option avant Jesus Christ (si activée)" - wrong_complex_datation_format: "Ne respecte pas le format %{field_format} du champ complex datation" - wrong_date_time_format: "Ne respecte pas le format %{field_format} du champ date time" + wrong_format: "Ne respecte pas le format %{field_format}" field/choice_set: attributes: choice_set_id: