Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once (APPLICATION_PATH . "/classes/PasswordConfirmation.php");
- class CreateForm extends Zend_Form
- {
- protected $_hiddenElementDecorator = array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'hidden')));
- protected $_normalElementDecorator = array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'normal')), array('Label'), array('tag' => 'div', 'class' => 'normal'));
- public function __construct ($options = null)
- {
- parent::__construct($options);
- $this->setName('users');
- }
- public function init()
- {
- $userid = new Zend_Form_Element_Hidden('UserID');
- $username = new Zend_Form_Element_Text('UserName');
- $username->setLabel('Username')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('Db_NoRecordExists', false, array('table' => 'users' , 'field' => 'UserName'))->addValidator('NotEmpty');
- $password = new Zend_Form_Element_Password('UserPassword');
- $password->setLabel('Password')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator(new Validate_PasswordConfirmation());
- $password_c = new Zend_Form_Element_Password('UserPasswordConfirm');
- $password_c->setLabel('Password Confirmation')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
- $email = new Zend_Form_Element_Text('UserEmail');
- $email->setLabel('Email')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('Db_NoRecordExists', false, array('table' => 'users' , 'field' => 'UserEmail'))->addValidator('NotEmpty');
- $submit = new Zend_Form_Element_Submit('submit');
- $submit->setLabel('Register');
- $submit->setAttrib('id', 'submitbutton');
- $this->addElements(array($userid , $username , $password , $password_c , $email , $submit));
- }
- public function loadDefaultDecorators() {
- foreach ($this->getElements() as $element) {
- if ($element->getType() === "Zend_Form_Element_Hidden") {
- $element->setDecorators($this->_hiddenElementDecorator);
- } else {
- $element->setDecorators($this->_normalElementDecorator);
- }
- }
- parent::loadDefaultDecorators();
- }
- }
Add Comment
Please, Sign In to add comment