I have a question about the Zend Framework 2, can some one provide an example code or link of how I can attach a validator class to the form in my controller so that it displays the error messages from the validator. A Zend framework developer has suggested me to use this
$form->getInputFilter()->get('entityName')->getValidatorChain()->add($validator);
when I added this line in my controller, throws me this error when I try to add a new entity
Fatal error: Call to undefined method Zend\Validator\ValidatorChain::add() in C:\Album\src\Album\Controller\AlbumController.php
In case if somebody familiar with Zend Framework can help me to sort out this. I am purely searching for ways to add the validator to my form in controller. Any suggestions would be appreciated.
P.S. My AlbumController code can be found here
I’m sorry, it’s actually
addValidator($validator), not justadd($validator).But you could have seen this if you had a look at the sources.
Also, I don’t think it was necessary to create a new question for this. I would have answered this also in your latest question.
// Edit: oops, just saw that you asked in your latest question, sorry for this.