Skip to content

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

Closed
wants to merge 1 commit into from

2 participants

@alivesay

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

@carlosantoniodasilva

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

@alivesay

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?

@carlosantoniodasilva

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.

@alivesay

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
Something went wrong with that request. Please try again.