Welcome Guest, Not a member yet? Register   Sign In
a custom callback to check if the value is empty
#1

[eluser]dedenf[/eluser]
Hi,
first of all i'm sorry if this kind of question is already posted, i've been search and not found any result that match my case.

i make a custom callback function to check if the value is empty or not, and to make a custom message for it
Code:
function number_check($val){
if(empty($str)){
   $this->validation->set_message('number_check', '%s cannot be empty');
   return FALSE;
  }
}
and its not run by CI, when i look to the Validation Libraries(Validation.php), i found this on line 200
Code:
if ( ! isset($_POST[$field]) OR $_POST[$field] == '')
{
   continue;
}
CI will always skip my callback if that $str(means the value of the field) doesn't have any value, and my callback function won't be read by validation library.
the validation rules, only check if the field value is not empty. but when i commented the "continue;"
Code:
if ( ! isset($_POST[$field]) OR $_POST[$field] == '')
{
   //continue;
}
it works, my callback is not skipped by the CI Validation, even with the "required" rules on the other field rules.
i wonder, is that the purpose of the validation library? that i can't use the callback if the value is empty? i know that i can use required rules to check whether its empty or not, but in my case, i just want to make a custom message (in my language) on the different field.

Thanks
ps: i use CI 1.6.1


Messages In This Thread
a custom callback to check if the value is empty - by El Forum - 04-21-2008, 02:41 AM
a custom callback to check if the value is empty - by El Forum - 04-21-2008, 03:12 AM
a custom callback to check if the value is empty - by El Forum - 04-21-2008, 03:23 AM
a custom callback to check if the value is empty - by El Forum - 04-21-2008, 03:58 AM
a custom callback to check if the value is empty - by El Forum - 04-21-2008, 04:11 AM
a custom callback to check if the value is empty - by El Forum - 04-21-2008, 04:15 AM
a custom callback to check if the value is empty - by El Forum - 04-21-2008, 04:59 AM
a custom callback to check if the value is empty - by El Forum - 04-21-2008, 11:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB