Open kneekoo opened 9 years ago
@kneekoo Can you write a wiki article as you are an expert at this now :).
As mentioned on the IRC channel, you can do it this way - https://gist.github.com/rahuldroy/eb5de146a3e65da5efcb
or a better way would be to extend the validator classes override the default message templates. Once the overriding is completed, it will just need to be invoked either in your Module.php or module.config.php
An expert newbie, being really optimistic. :P The solution you mentioned on IRC works, but it leads to repetition:
The input was not found in the haystack
An invalid sex type was entered
An invalid sex type was entered
I'll see what I can do about the validator classes override. Thanks for the suggestions. :)
This can easily become Wiki material but right now it's a call for help. I added new fields to ZfcUser. One of them is sex. My problem here is with the validation messages. They work just fine but while editing users, manipulating the form's value (I changed it to "s") I got these messages:
Obviously, I only want to display the third message whenever the input data doesn't match my criteria. Anything else is not user-friendly. Zend's Validation Messages[1] page demonstrates how you can override messages but it doesn't say how you can restrict certain messages or only display what you want. I looked for solutions on the web and I also went to the ZF irc channel, but I didn't find what I needed. How can we output only our validation messages?
[1] http://framework.zend.com/manual/2.0/en/modules/zend.validator.messages.html
Here are the details of my custom field:
module\ZfcUser\src\ZfcUser\Form\Base.php -> __construct:
module\ZfcUser\src\ZfcUser\Form\RegisterFilter.php -> __construct:
module\ZfcUserAdmin\config\services.config.php ->
$filter = new $registerFilter(
module\ZfcUserAdmin\src\ZfcUserAdmin\Validator\SexEdit.php