![]() |
validation problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: validation problem (/showthread.php?tid=12097) |
validation problem - El Forum - 10-06-2008 [eluser]dimis[/eluser] I want to see if a text input is empty when a condition exists. So I extend validation and write this function. Code: function _check_text($str,$type) Dimis validation problem - El Forum - 10-06-2008 [eluser]xwero[/eluser] The required rule is to check if the field as a value. If the required rule isn't added and there is no value all the rules are omitted. validation problem - El Forum - 10-06-2008 [eluser]dimis[/eluser] I want only if $type['item']==$type['value'] to fill this input. is it Impossible? validation problem - El Forum - 10-06-2008 [eluser]xwero[/eluser] I don't think your check will ever be true or will always be true. The way your $type[‘item’]==$type[‘value’] works if you add an array to as the parameter to the rule with the keys item and value. The type of a POST value is most of the time a string but because php has weak typing you can check if it's numeric too. The numeric rule is in the Validation library and it also as a few rules to check the formating of the string. You could add a check to see if the value for the post key is an array but that is it so your function would look like this Code: function($val,$type) validation problem - El Forum - 10-06-2008 [eluser]dimis[/eluser] My code is Code: $test=array('item'=>$mylink,'value'=>'1'); validation problem - El Forum - 10-06-2008 [eluser]xwero[/eluser] You have to add the required rule. If there is no value there is no point of getting the type. validation problem - El Forum - 10-06-2008 [eluser]dimis[/eluser] Anyway, I put the conditions at my controller (if $check==something) ... validation rules .... |