I'm using Kohana 3.3 and trying to write a custom validation rule to ensure that users username and e-mail address are unique. I'm following the instructions from an SO question here, and the Kohana documentation here, but whenever I try to add in array(array($this, 'unique_email'))
I get syntax error, unexpected '$this' (T_VARIABLE), expecting ')'
.
If I put array(array('Model_User', 'unique_email'))
I don't get any errors, but why would using $this
cause an error? For completeness I've posted the full class below.
class Model_User extends ORM {
protected $_rules = array(
'email' => array(
array(array($this, 'unique_email')),
)
);
public function unique_email()
{
return TRUE;
}
}