开发者

Kohana 3.1 Validation conditional rule possible?

开发者 https://www.devze.com 2023-03-22 04:30 出处:网络
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

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 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消