• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using another rule if callback returns false

#1
[eluser]Unknown[/eluser]
I'm using the following rule for my input:

Code:
callback_validate_host

I need to make the following condition:

if
Code:
callback_validate_host
is FALSE afterwards it should use the valid_ip validation rule.

So if validation of both: callback_validate_host and valid_ip on one input if FALSE then is should throw an error message.

How can I do that?

#2
[eluser]CroNiX[/eluser]
Haven't tried this, but you might try:

1) In your callback, if validate_host() is TRUE, return TRUE and you're done, else
2) Run it through the valid_ip() rule, like $valid_ip = $this->CI->form_validation->valid_ip($str);
3) If $valid_ip === TRUE, return TRUE, if FALSE, set an error message for "validate_host" (as opposed to valid_ip since validate_host is the name of your callback rule) and return FALSE. I don't think it will automatically find the error message for the valid_ip rule since it wasn't set up as an original rule in form_validation:Confusedet_rules();

Again, I haven't tried this.



Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.