When I have some validation errors in the changeset I want to be able to say to the end user: "credit card can't be blank", or something more complex such as: "your awesome credit card can't be blank".
In short I want the same feature of that: http://gothamjs.io/documentation/1.0.0/validator#change-attributes
I didn't find on the guides something like that, so I came up with that:
error_helpers.ex
@doc """
Generates tag for inlined form input errors.
"""
def error_tag(form, field) do
if error = form.errors[field] do
content_tag :span, to_string(field) <> " " <> translate_error(error), class: "help-block"
end
end
You can see I just added to_string(field)
I guess I can come up with an hacky solution with gettext, to translate the field to reach my goal, but I think it's a big no-no to do that.
Doesn't phoenix provide something similar out of the box ? If not, what's the best way to tackle that ?