Welcome Guest, Not a member yet? Register   Sign In
how to do unique validation, CodeIgniter2 + Doctrine2
#2

[eluser]xjermx[/eluser]
Well I've found a solution. I'm not sure if its the best or most elegant, but it works.

Code:
$this->form_validation->set_rules('email', 'E-mail',
                 'required|valid_email|callback_email_check');

Code:
public function email_check($str)
{
$user = $this->doctrine->em->getRepository('Entities\User')->findOneBy(array('email' => $str));
    if (isset($user)) {
            $this->form_validation->set_message('email_check', 'This email address is already in use');
                    return FALSE;
    } else
    {
        return TRUE;
    }
}

Still open to anyone offering opinions on how this might be done better!


Messages In This Thread
how to do unique validation, CodeIgniter2 + Doctrine2 - by El Forum - 04-06-2012, 09:25 AM
how to do unique validation, CodeIgniter2 + Doctrine2 - by El Forum - 04-06-2012, 12:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB