Error_messages_for - Custom formating

Hi all,

I am trying to change the default formatting for the error_messages_for.

To quote from the ROR manual:

///////////

error_messages_for(object_name, options = {})

Returns a string with a div containing all the error messages for the
object located as an instance variable by the name of object_name. This
div can be tailored by the following options:

header_tag - Used for the header of the error div (default: h2)
id - The id of the error div (default: errorExplanation)
class - The class of the error div (default: errorExplanation)

NOTE: This is a pre-packaged presentation of the errors with embedded
strings and a certain HTML structure. If what you need is significantly
different from the default presentation, it makes plenty of sense to
access the object.errors instance yourself and set it up. View the
source of this method to see how easy it is.

///////////

So if I wanted to change the header tag to a h4 and change the default
id and class, I presume I would use this

<%= error_messages_for(‘signup’, options = {:header_tag => ‘h4’, :id =>
‘myid_name’, :class => ‘myclass_name’}) %>

However that doesn’t seem to change the default settings.

Also how can I change the overall html structure of the errors? For
example use

    instead of
    's. I could just edit the original file,
    just I guess I need a helper to do this?

    I am new to ROR, so sorry if this an easy question.

    Thanks,

    Steve

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs