Studyon Minte9.com
ZF 1.0




Validators



#modules/default/Forms/Login.php
<?php
	class Forms_Login extends Zend_Form {
		
		public function init() {
			
			$this->setMethod('post');
			$this->setEnctype('multipart/form-data');

			$username = new Zend_Form_Element_Text('username', array(
				'required' => true,
				'label'	=> 'Username:',
				'filters' => array('StringTrim', 'StringToLower'),
				'validators' => array(
					'Alnum',
					array('Regex', false, array('/^[a-z][a-z0-9]{2,}$/')),
				),
			));

			$password = new Zend_Form_Element_Password('password', array(
				'required' => true,
				'label' => 'Password:',
				'filters' => array('StringTrim'),
				'validators' => array(
					'NotEmpty',
					array('StringLength', false, array(6)),
				),
			));
			
			$submit = new Zend_Form_Element_Submit("submit");
			$submit->setLabel("Submit");

				
			// add elements
			$this->addElements(array(
				$username,
				$password,
				$submit,
			));
		}
	}


---
form.01.overview
form.04.viewscript


http://zendguru.wordpress.com/2008/12/05/grouping-form-errors-for-display-purpose/
http://framework.zend.com/manual/en/zend.form.elements.html