Ruby on Rails Friday, December 31, 2010

Hi,
Here is a couple of things that I found myself doing for customizing
the error messages:
1 alter the result of the error_messages_for helper (for example to
use gsub to make some small updates);
2 redefine the "ActionView::Base.field_error_proc" to your own
procedure;
3 add some additional YAML code to your locales file to specify the
different error message.
--
Hope it was helpful, Ivan Povalyukhin

On Dec 30, 1:56 pm, djangst <djan...@gmail.com> wrote:
> Does anybody know a good way to completely customize validation
> output? I've tried a number of options but can only get partway there.
>
> For example I'd like to style not only the affected form input but
> also its label, and provide a message (common to many apps). This has
> been problematic, as the input is referenced internally by 'html_tag'
> and at that point its associated label is out of scope:
>
> http://edgeguides.rubyonrails.org/active_record_validations_callbacks...
>
> I've added the message using this method but can't get at the label.
>
> I've also created an auto-labeling form builder (http://
> edgeguides.rubyonrails.org/form_helpers.html#customizing-form-
> builders) but the error handling still only grabs the input itself
> after the form has been built (i.e., it doesn't view my custom labeled
> input as a sort of composite control).
>
> I can accomplish this in the view conditionally by checking
> @instance.errors on a per-field basis, but this seems clunky. And if I
> do that, doesn't all the validation stuff still fire internally,
> burning cycles on something I don't use?
>
> There must be a good way to automate this.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment