Show error message for just the displayed locale

Unfortunately the builder didn't offer any options for the error message
and we just had to overwrite the `error_for` methods.
This commit is contained in:
Javi Martín
2018-10-11 11:09:38 +02:00
committed by decabeza
parent 87484015da
commit a48db19c05

View File

@@ -77,6 +77,16 @@ module TranslatableFormHelper
@template.display_translation_style(@object.globalized_model, locale) @template.display_translation_style(@object.globalized_model, locale)
end end
def error_for(attribute, options = {})
final_options = translations_options(options).merge(class: "error js-globalize-attribute")
return unless has_error?(attribute)
error_messages = object.errors[attribute].join(', ')
error_messages = error_messages.html_safe if options[:html_safe_errors]
content_tag(:small, error_messages, final_options)
end
private private
def help_text(text) def help_text(text)
if text if text