I'm trying to use a custom validation method in cakephp 2.2.2 but for some reason the function isn't being called. Custom validation methods worked on the same system when I used cakephp for another project.
I found a question on stack overflow with what seemed to be the same problem, but there wasn't a solution (Custom filed validation in CakePHP).
This is the code in my model:
<?php
App::uses('AppModel', 'Model');
class Person extends AppModel {
public $validate = array(
'dob' => array(
'date' => array(
'rule' => array('date'),
),
'date_between' => array(
'rule' => array('dateBetween', '01/01/1996'),
'message' => 'You are not the right age to enter',
),
),
);
public function dateBetween($v1, $v2) {
dump_var($v1);
dump_var($v2);
return false;
}
}
Note: dump_var()
is a var_dump()
with the pre tags around it.