Created
May 16, 2013 21:19
-
-
Save smolak/5595192 to your computer and use it in GitHub Desktop.
ZFCRUD users 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 Aadmin_Form_Users extends Zend_Form | |
{ | |
public function init() | |
{ | |
/** | |
* You would probably like to add some more filters / validators | |
* to check all things. This is meant only to be a simple example. | |
*/ | |
$name = new Zend_Form_Element_Text('name'); | |
$name->setRequired() | |
->addFilter('StringTrim') | |
->addValidator('NotEmpty', true) | |
->setLabel('Name'); | |
$this->addElement($name); | |
$vDbNoRecordExist = new Zend_Validate_Db_NoRecordExists( | |
array( | |
'table' => 'users', | |
'field' => 'login' | |
) | |
); | |
$login = new Zend_Form_Element_Text('login'); | |
$login->setRequired() | |
->addFilter('StringTrim') | |
->addValidator('NotEmpty', true) | |
->addValidator($vDbNoRecordExist, true) | |
->setLabel('Login'); | |
$this->addElement($login); | |
$password = new Zend_Form_Element_Password('password'); | |
$password->setRequired() | |
->addValidator('NotEmpty', true) | |
->setLabel('Password'); | |
$this->addElement($password); | |
$vIdentical = new Zend_Validate_Identical('password'); | |
$repeatPassword = new Zend_Form_Element_Password('password_repeat'); | |
$repeatPassword->setRequired() | |
->setIgnore(true) | |
->addValidator('NotEmpty', true) | |
->addValidator($vIdentical, true) | |
->setLabel('Repeat password'); | |
$this->addElement($repeatPassword); | |
$email = new Zend_Form_Element_Text('email'); | |
$email->setRequired() | |
->addFilter('StringTrim') | |
->addValidator('NotEmpty', true) | |
->addValidator('EmailAddress', true) | |
->setLabel('Email'); | |
$this->addElement($email); | |
$submit = new Zend_Form_Element_Submit('submit'); | |
$submit->setLabel('Create new user') | |
->setIgnore(true); | |
$this->addElement($submit); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment