addElement('email', 'email', array('label' => 'Enter your email address', 'required' => true)); $validatorRecordExists = new Zend_Validate_Callback(['callback' => [$this, 'validateEmail']]); $validatorRecordExists->setMessage( 'There is no user with %value% email in our system', Zend_Validate_Callback::INVALID_VALUE ); $this->getElement('email')->addValidator($validatorRecordExists); return $this; } public function validateEmail($value) { if ($value) { $dbObj = new Obj(); $dbObj->setPrimaryKeyByEmail($value); if (!$dbObj->getPrimaryKey()) { return false; } } return true; } protected function _initButtons() { if (!$this->_hasButtons) { return $this; } $this->addElement( 'submit', 'btnSubmit', array('label' => 'Reset Password', 'attribs' => array('class' => 'btn btn-primary')) ); return $this; } }