Hello Everyone,
I am trying to get my UniqueEmail validator working but it seems that my validator is never triggered.
This is my form:
class EventManager_Form_User_Base extends SF_Form_Abstract{
public function init(){
$this->addElementPrefixPath(
'EventManager_Validate',
APPLICATION_PATH . '/modules/eventManager/models/validate',
'validate'
);
(...)
$this->addElement('text','usr_email', array(
'filters' => array('StringTrim', 'StringToLower'),
'valdators' => array(
array('StringLength',true,array(3,128)),
array('EmailAddress'),
array('UniqueEmail', false, array(new EventManager_Model_User())),
),
'required' => true,
'label' => 'email',
));
(...)
}
}
And here is my validator
class EventManager_Validate_UniqueEmail extends Zend_Validate_Abstract{
const EMAIL_EXISTS = 'emailExists';
protected $_messageTemplates = array(
Self::EMAIL_EXISTS => 'Email "%value%" already exists in our system',
);
public function __constructs(EventManager_Model_User $model){
$this->_model = $model;
}
public function isValid($value,$context = null){
$this->_setValue($value);
$currentUser = isset($context['usr_id']) ? $this->_model->getUserById($context['user_id']) : null;
$user = $this->_model->getUserByEmail($value, $currentUser);
if(null === $user){
return true;
}
$this->_error(self::EMAIL_EXISTS);
return false;
}
}
When I add the line
var_dump($value); exit;
in the first line of my isValid() function and then run my form. then the code just runs but seems not to get into my validator.
I am running zf 1.10.1 any idea's / suggestions?