CodeIgniter Forums
Update code from ci 1.6 to ci 2.0 getting error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter Archived (from EllisLab) (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Update code from ci 1.6 to ci 2.0 getting error (/thread-41026.html)



Update code from ci 1.6 to ci 2.0 getting error - El Forum - 04-26-2011

[eluser]Unknown[/eluser]
Code:
function _set_fields(){
        $fields['id'] = 'id';
        $fields['name'] = 'name';
        $fields['gender'] = 'gender';
        $fields['dob'] = 'dob';

        $this->validation->set_fields($fields);
    }

    // validation rules
    function _set_rules(){
        $rules['name'] = 'trim|required';
        $rules['gender'] = 'trim|required';
        $rules['dob'] = 'trim|required|callback_valid_date';

        $this->validation->set_rules($rules);

        $this->validation->set_message('required', '* required');
        $this->validation->set_message('isset', '* required');
        $this->validation->set_error_delimiters('<p class="error">', '</p>');
    }

and give this error:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Person::$validation

Filename: controllers/person.php

Line Number: 168

Fatal error: Call to a member function set_fields() on a non-object in C:\wamp\www\bebas\application\controllers\person.php on line 168


what's wrong with that code?


Update code from ci 1.6 to ci 2.0 getting error - El Forum - 04-26-2011

[eluser]n0xie[/eluser]
The Validation library is depreciated and replaced by the Form_Validation library