Error messages in Zend Form .ini file
24Jul10I was searching the way to customize the validator error messages in Zend Form using the .ini file.
Finally I found two useful links:
I copy here the content of my form.ini:
; apellido elements.apellido.type = "text" elements.apellido.options.label = "Apellido" elements.apellido.options.description = "Introduce tu apellido" elements.apellido.options.validators.notempty.validator = "NotEmpty" elements.apellido.options.validators.notempty.options.messages.isEmpty = "Campo requerido" elements.apellido.options.validators.notempty.breakChainOnFailure = true elements.apellido.options.validators.strlen.validator = "StringLength" elements.apellido.options.validators.strlen.options.min = "1" elements.apellido.options.validators.strlen.options.max = "100" elements.apellido.options.required = true
Some useful tips that you might know:
- If you don’t put the “options.required = true” the “NotEmpty” validator doesn’t work.
- If you don’t put the “breakChainOnFailure = true” the form will carry on executing other validators.
- You can search in the Zend Framework source code for the messages that you can overwrite. Look at: “Zend/Validate/*” files.
I wish it will be useful for somebody =) !