Kohana 3.1 Validation conditional rule possible?
Is it at all possible to create a conditional rule with Kohana 3.1 Validation::factory()?
For example I have a radio button which if the user clicks on it, then I want to apply rules to another group of entry fields, like 'not_empty' ( but only if the user clicks on that radio button ).
Looking at all the docs for 3.1 it appears开发者_运维知识库 that nothing allows me to do such a thing!
Err... use if
statement? Either you use GET/POST the relevant input field and its value would be available, you could use that to check for radio button click, then add rule only if it exists. e.g.:
$val = Validation::factory(...); // fill as necessary
if ($_POST['myradio']) {
$val->rule(...); // now apply that 'conditiona' rule
}
精彩评论