I've go some validation functions written to check if the user's email exists in the system.
I am getting the following error
Notice (8): Undefined offset: 0 [CORE/cake/libs/model/model.php, line 1122]
This is the code which causes the error
'email' => array(
'emailRule-1' => array(
'rule' => 'email',
'message' => 'email format is incorrect',
'last' => true
),
'emailRule-2' => array(
'rule' => 'checkEmailExist',
'message' => 'email already exists in the system'
)
),
And rule2 seems to be responsible for the error, and here is the rule2:
function checkEmailExist($emailAddress, $user_id){
$this->recursive = -1;
if($user_id > 0){
$user = $this->read(array('email'), $user_id);
if($emailAddress == $user['User']['email'])
return true;
}
$result = $this->find('count', array('conditions' => array('User.email' => $emailAddress)));
return $result > 0 ? false : true;
}