array('asBilling' => 'y')); /** * @return App_User_Admin_Obj */ protected function _getDataObj() { if (null === $this->_dataObj) { $this->_dataObj = new App_User_Admin_Obj(); } return $this->_dataObj; } protected function _initElements() { $this->_initPersonalInfoFields(); return $this; } protected function _initPersonalInfoFields() { $this->addElement('text', 'login', array('label' => 'Username', 'required' => true)); $uniqueValidator = new Qs_Validate_Unique(new Qs_Db_Table('User'), 'login', $this->_getData('id')); $uniqueValidator->setMessage('Login Name must be unique', Qs_Validate_Unique::NOT_UNIQUE); $this->getElement('login')->addValidator($uniqueValidator); $this->addElement( 'password', 'password', array('label' => 'Password', 'attribs' => array('autocomplete' => 'off')) ); $this->getElement('password')->addValidator('Callback', true, array(array($this, 'validatePassword'))); $this->addElement( 'password', 'confirmPassword', array('label' => 'Confirm Password', 'attribs' => array('autocomplete' => 'off')) ); $this->getElement('confirmPassword')->addValidator('ConfirmPassword', true, array('password')); return $this; } public function render(Zend_View_Interface $view = null) { /** @var $doc App_Doc_Admin */ $doc = Zend_Registry::get('doc'); $doc->addScript('js/app/user/form.js'); $options = array(); $options['formId'] = $this->getId(); $doc->addInitObject('App_User_Form', array($options), 'appUserForm'); return parent::render($view); } public function validatePassword($value, $context = null) { if (!empty($value) && empty($context['confirmPassword'])) { $this->getElement('confirmPassword')->setRequired()->isValid(''); $this->getElement('confirmPassword')->setErrors(array('Password confirmation does not match')); } return true; } }