Display field name in errors w/ config.wrapper option :prefix_attribute_name #729

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

This adds the ability to prefix error messages through a config.wrapper option :prefix_attribute_name.

Collaborator

Can you expand a little bit more your use case for this please?

I want the "full_error" message to display on my forms like this:
inlineerrors

The only option I see to display the full_error without this patch is to do something like this inside my form:

 <%= f.full_error :token %>

The problem with this is that the error message tag is displayed outside the controls div. Am i missing something?

Collaborator

It seems duplication to me to have the field name in the label and in the error message. Anyway, you can achieve it with something like this:

<%= f.input :email, error: false do %>
  <%= f.input_field :email %>
  <%= f.full_error :email %>
<% end %>

That should give you the expected output.

That's works perfectly -- thanks!

@alivesay alivesay closed this Jan 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment