CodeIgniter Forums

Full Version: Unable to Access an Error Message Corresponding to Your Field Name
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]01010011[/eluser]
Hi,
I've created this registration form (see attached) that registers new users and checks whether their user name already exists in the database.

The problem is, instead of displaying the error message I wrote, it displays this error message:
Quote:Unable to access an error message corresponding to your field name

How do I correct this? Any assistance will be appreciated. Thanks in advance.

El Forum

[eluser]01010011[/eluser]
Hi,
I figured out what the problem was: my message key did not match my function name: http://ellislab.com/codeigniter/user-gui...ation.html

El Forum

[eluser]$ilovephp[/eluser]
This is your code:
Code:
function username_not_exists($username)
{
            
$this->form_validation->set_message('username','That %s already exists. Please choose a different username and try again');
            
    if($this->User_model->check_exists_username($username))
    {
        return false;
    }
    else
    {
        return true;
    }
}

try editing your above code with this below:

Code:
function username_not_exists($username)
{
            
$this->form_validation->set_message('username_not_exists','That %s already exists. Please choose a different username and try again');
            
if($this->User_model->check_exists_username($username))
{
    return false;
}
else
{
    return true;
}
}

Notice the $this->form_validation->set_message(), instead of 'username', we change the first parameter with the 'username_not_exists' which is the name of your call back method.

El Forum

[eluser]$ilovephp[/eluser]
[quote author="01010011" date="1271644784"]Hi,
I figured out what the problem was: my message key did not match my function name: http://ellislab.com/codeigniter/user-gui...ation.html[/quote]

Oops.. i did not notice your reply..

El Forum

[eluser]marcoslavorato[/eluser]
Really thanks $ilovephp, works fine. I was with the same problem.