i am trying to validate a user registration form in Zend Framework 2.
More specifically how to validate the email, ZF1 i could do:
$email->setValidators( array(new Zend_Validate_EmailAddress()) );
I’m wondering if i can just call something similar like this.
Also I’m wondering how to validate two fields that need to be the same like the password field and the password verification.
I guess that when i say if($form->isValid()).. this will check the getInputFilter() method for all validation.
I’ve been taking a look at ZfcUser module but, right now, i can’t understand much since i don’t have a full grasp on how ZF2 works
Any ideas, maybe a simple example?
thanks
Have you read the official tutorial to see how the new ZF2
Formcomponent works?At a very high level, you need a
Formobject and aFilterobject working together. TheFilterobject is where you place your filters and validators. However, if you use a form element of typeEmailAddressin yourForm, then it will automatically add the correct validator. There is more information in the manual.I recently did a webinar on forms for Zend which you should be able to find on this page.