Created
September 1, 2011 23:21
-
-
Save justinkelly/1187557 to your computer and use it in GitHub Desktop.
Simple Password confirmation with Zend_Form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Application_Form_User extends Zend_Form | |
{ | |
public function init() | |
{ | |
/* Form Elements & Other Definitions Here ... */ | |
$this->setName('user'); | |
$id = new Zend_Form_Element_Hidden('id'); | |
$id->addFilter('Int'); | |
// add all your field here.... | |
$email = new Zend_Form_Element_Text('email'); | |
$email->setLabel('Email') | |
->setRequired(true) | |
->addFilter('StripTags') | |
->addFilter('StringTrim') | |
->addValidator('EmailAddress') | |
->addValidator('NotEmpty'); | |
$password = new Zend_Form_Element_Password('password'); | |
$password->setLabel('Password') | |
->addFilter('StripTags') | |
->addFilter('StringTrim'); | |
/* password confirmation - just set the token section to the password field name */ | |
$confirmPswd = new Zend_Form_Element_Password('confirm_pswd'); | |
$confirmPswd->setLabel('Confirm Password:'); | |
$confirmPswd->setAttrib('size', 35); | |
$confirmPswd->setRequired(true); | |
$confirmPswd->addValidator('Identical', false, array('token' => 'password')); | |
$confirmPswd->addErrorMessage('The passwords do not match'); | |
$submit = new Zend_Form_Element_Submit('submit'); | |
$submit->setAttrib('id', 'submitbutton'); | |
$this->addElements(array($id, | |
$email, $password, $confirmPswd, | |
$submit)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment