Welcome Guest, Not a member yet? Register   Sign In
Validation problem - Config | Callback | Controller
#1

[eluser]Multisnet[/eluser]
I need some help please..

I'm dealing with validation. After read the User Guide topic I decided to create a config file with rules for validation.

form_validation.php example:

Code:
$config = array(
            'registoPaciente'=>array(
                   array(
                         'field'   => 'nome',
                         'label'   => 'Nome',
                         'rules'   => 'required|alpha'
                      ),
                   array(
                         'field'   => 'apelido',
                         'label'   => 'Apelido',
                         'rules'   => 'required|alpha'
                      ),
                   array(
                         'field'   => 'email',
                         'label'   => 'Email',
                         'rules'   => required|callback_verificaEmail'
                      )
)

in the controller I use
Code:
if ($this->form_validation->run('registoPaciente') == FALSE)
        {
            (...)
        }
        else
        {
            (...)
        }

The problem is in the callback verificaEmail. In the controller I implemented this method for test
Code:
function verificaEmail($str)
    {
    if ($str == '[email protected]')
        {
[b]echo "TEST";[/b]
        $this->form_validation->set_message('email_existente', 'Error in e-mail');
        return FALSE;
        }
    else
        {
        return TRUE;
        }
    }

When I run the application the Test message is displayed, however it return this error for the email field:
Unable to access an error message corresponding to your field name.

Could you help me?

PS:Some expressions are in Portuguese but I think that I translated everything relevant.

Thanks in advance


Messages In This Thread
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 08:42 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 08:54 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 08:55 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 08:57 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 09:01 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 09:11 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 09:45 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 09:54 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 10:04 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 10:05 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 10:21 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 10:22 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 10:24 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 11:58 AM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 12:56 PM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 01:23 PM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 01:29 PM
Validation problem - Config | Callback | Controller - by El Forum - 06-24-2009, 03:02 PM
Validation problem - Config | Callback | Controller - by El Forum - 06-25-2009, 06:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB