Welcome Guest, Not a member yet? Register   Sign In
form validation callback
#2

[eluser]Cro_Crx[/eluser]
Hey timaksu

You can write a really short callback function to do that

In your validation rules you would have something like this

Code:
$this->form_validation->set_rules('field', 'Field Name', 'callback__check_if_exists');

Then just write a callback function. Notice how i've put another underscore, this keeps the function private so it can't be accessed externally by a user directly.

Code:
function _check_if_exists()
{
    $this->form_validation->set_rules('_check_if_exists', 'Username already exists');
    return (!$this->user_model->exists($str));
    // we return the opposite, so if the user exists we return false and true if they don't exist.
  
}


Messages In This Thread
form validation callback - by El Forum - 07-14-2009, 04:58 AM
form validation callback - by El Forum - 07-14-2009, 06:04 AM
form validation callback - by El Forum - 07-14-2009, 06:06 AM
form validation callback - by El Forum - 07-14-2009, 06:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB