views:

630

answers:

2

Hi

I am using INI files to manage my Zend_Form elements.

Here's an example .ini file:

form.action = ""
form.method = "post

form.elements.attribute_name.type = "text"
form.elements.attribute_name.options.label = "Element Name"
form.elements.attribute_name.options.validators.strlen.validator = "StringLength"
form.elements.attribute_name.options.validators.strlen.options.min = "1"
form.elements.attribute_name.options.validators.strlen.options.max = "50"

form.elements.submit.type = "submit"
form.elements.submit.options.name = "Go!"

This element will throw the "strlen" error message as "XX is greater than 50 characters long"

My question is: How do i overwrite this error message within in INI file?

I thought the following might work, but it doesnt do anything!

form.elements.attribute_name.options.validators.strlen.options.message = "You Muppet!"

Thanks for any help.

Jon

+3  A: 

I think you need to select which specific validation message you want to override.

Try this:

form.elements.attribute_name.options.validators.strlen.options.messages.stringLengthInvalid = "You Muppet!"
form.elements.attribute_name.options.validators.strlen.options.messages.stringLengthTooShort = "You Muppet!"
form.elements.attribute_name.options.validators.strlen.options.messages.stringLengthTooLong = "You Muppet!"

Of course, I could be wrong!

Rob Allen
A: 

Bingo! Thanks to Rob Allen's post I've managed to figure it out. The correct INI code is:

form.elements.attribute_page.options.validators.strlen.options.messages.stringLengthTooLong = "You Muppet!"

Thanks Rob!

Jon Reeks
Great! I've updated my answer so that it's no longer providing incorrect information :)
Rob Allen