I am a reletively newbie to the Zend Framework, I am busy with a simple application which does not require the entire MVC structure of the framework, so I have set my include path to see the Zend Framework Library.
So far I have managed to setup a simple login form. But what I am struggling with now is the form validation does not occur in my form.MY code looks like this:
$form = new Zend_Form();
$form->setView(new Zend_View())
->setAction('includes/login.php')
->setMethod('post')
->setAttrib('id', 'login');
$username = new Zend_Form_Element_Text('username');
$username->addValidator(new Zend_Validate_Alnum())
->setLabel('username')
->setRequired(true);
$password = new Zend_Form_Element_Password('password');
$password->addValidator('StringLength', false, array(5))
->setLabel('password')
->setRequired(true);
$login = new Zend_Form_Element_Submit('login');
$login->setLabel('login');
$form->addElement($username)
->addElement($password)
->addElement($login);
echo $form->render();
I'm not sure how exactly one would use the validation classes/methods in this instance, does anyone perhaps have a guide and tutorial I could use or maybe point me in the right direction cause I am not sure if what I did is correct ?
ldevstarx
Zend_Validate_*classes are for server side validation. - BartekR