Welcome Guest, Not a member yet? Register   Sign In
Unable to Access an Error Message Corresponding to Your Field Name
#1

[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.
#2

[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
#3

[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.
#4

[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..
#5

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




Theme © iAndrew 2016 - Forum software by © MyBB