class Myvalidation { public function _validation_dob($d, $m, $y) { if ($d == "0" && $m == "0" && $y == "0") return false; } }
$val->add_field('day', 'Your date of birth', 'dob[d,m,y]');
public function _validation_dob() { if (Input::post('day') == "0" && Input::post('month') == "0" && Input::post('year') == "0") return false; }
public function _validation_dob() { $val = Validation::instance(); if ($val->input('day') == "0" && $val->input('month') == "0" && $val->input('year') == "0") return false; }
Jelmer Schreuder wrote on Monday 18th of April 2011:Currently the only rule that does something similar is within the Validation class: match_field That works because it can get the Validation instance to ask for the input. However, if you will only use this with POSTed values and never with manual input you could just check Input::post() for all three values:public function _validation_dob() { if (Input::post('day') == "0" && Input::post('month') == "0" && Input::post('year') == "0") return false; }
Or if you only use 1 unnamed Validation instance:public function _validation_dob() { $val = Validation::instance(); if ($val->input('day') == "0" && $val->input('month') == "0" && $val->input('year') == "0") return false; }
Otherwise, if you need to check the other values from the form input you'll have to extend the validation class to be able to use $this->input(). I'll think about making that available in another way outside the class, the problem is that if you use multiple validation instances there's no way for you method to figure out which instance to ask the given input from.
It looks like you're new here. If you want to get involved, click one of these buttons!