_dfRelations = $this->getConfigArray('dfRelations'); return parent::init(); } protected function _initElements() { $this->addElement( 'radio', 'resetType', [ 'label' => 'How do you wont to reset your password?', 'required' => true, 'multiOptions' => [ 'email' => 'Send a message to my email address', 'question' => 'Use my secret question', ], ] ); $this->addElement('email', 'email', ['placeholder' => 'Enter your email address']); $email = $this->getElement('email'); $email->getDecorator('HtmlTag')->setOption('style', 'display: none;'); $email->getDecorator('Label')->setTagOption('class', 'hidden'); if ('email' == $this->_getData('resetType')) { $email->setRequired(); $validatorRecordExists = new Zend_Validate_Db_RecordExists( Qs_Db::getTableName('User'), 'email', null, Qs_Db::getInstance() ); $validatorRecordExists->setMessage( 'There is no user with %value% email in our system', Zend_Validate_Db_RecordExists::ERROR_NO_RECORD_FOUND ); $email->addValidator($validatorRecordExists); } $this->addElement('text', 'login', ['placeholder' => 'Enter your login']); $login = $this->getElement('login'); $login->getDecorator('HtmlTag')->setOption('style', 'display: none;'); $login->getDecorator('Label')->setTagOption('class', 'hidden'); if ('question' == $this->_getData('resetType')) { $login->setRequired(); $validatorRecordExists = new Zend_Validate_Db_RecordExists( Qs_Db::getTableName('User'), 'login', null, Qs_Db::getInstance() ); $validatorRecordExists->setMessage( 'There is no user with %value% login in our system', Zend_Validate_Db_RecordExists::ERROR_NO_RECORD_FOUND ); $login->addValidator($validatorRecordExists); } return $this; } protected function _initButtons() { if (!$this->_hasButtons) { return $this; } $this->addElement( 'submit', 'btnSubmit', ['label' => 'Reset Password', 'attribs' => ['class' => 'btn btn-primary']] ); return $this; } }