Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Call to a member function set_message() on a non-object in...
#1

[eluser]Noisy[/eluser]
I'm using the Form Validation class with some callback functions. To be exact 4 fields with callback functions and 3 of them give me the error.

At first I use
Code:
'rules' => 'trim|required|xss_clean|valid_email|callback_email_check'
as rule, without any problems. The callback function looks like this
Code:
function email_check($mail)
    {
        $this->db->flush_cache();
        $this->db->select('email');
        $this->db->where('email', $this->db->escape($mail));
        $result = $this->db->count_all_results('users');
                
        if($result == 0 AND !empty($mail))
        {
            return true;
        }else{
                        $this->validation->set_message('email_cheack', 'Diese eMail-Adresse ist bereits bei uns registriert.');
            return false;
        }
    }

The second rule
Code:
'rules' => 'trim|required|xss_clean|callback_check_anrede'
and the corresponding function
Code:
function check_anrede($param)
    {
                $var = in_array($param, array('Herr', 'Frau'));
                
                if($var)
                {
                    return true;
                }else{
                    $this->validation->set_message('check_anrede', 'Verwenden Sie bitte nur "Herr" oder "Frau" als Anrede.');
                    return false;
                }
    }

I really don't know why I get this messages. To me both functions like exactly the same in their structure.
#2

[eluser]ivaylok[/eluser]
[quote author="Noisy" date="1276992625"]I'm using the Form Validation class ...

Code:
$this->validation->set_message('email_cheack', 'Diese eMail-Adresse ist bereits bei uns registriert.');
[/quote]
Try changing the above code with:
Code:
$this->form_validation->set_message('email_cheack', 'Diese eMail-Adresse ist bereits bei uns registriert.');

Do the same with the other error messages.
#3

[eluser]Noisy[/eluser]
Ok, I noticed this as well and changed it. The result was disillusioning. I don't get any PHP error, but now I get
Quote:Unable to access an error message corresponding to your field name.
So the message can't be set, but why? Even though the field is correctly filled, so that shouldn't be any error message displayed.
#4

[eluser]ivaylok[/eluser]
Take a look here: Form Validation : CodeIgniter User Guide.
It is quite neatly explained, I'm sure you will be fine.




Theme © iAndrew 2016 - Forum software by © MyBB