addElement('password', 'currentPassword', ['label' => 'Current Password', 'required' => true]); $this->getElement('currentPassword')->addValidator('Callback', true, [[$this, 'validateCurrentPassword']]); /** @var Zend_Validate_Callback $callback */ $callback = $this->getElement('currentPassword')->getValidator('Callback'); $callback->setMessage('Password is wrong', Zend_Validate_Callback::INVALID_VALUE); $this->_initPasswordFields(); return $this; } public function validateCurrentPassword($value, $context = null) { if (!empty($value)) { $data = $this->getDoc()->getAuth()->getStorage()->read(); if (Qs_Array::get($data, 'credential') != $value) { return false; } } return true; } }