Welcome Guest, Not a member yet? Register   Sign In
new with codeigniter
#17

[eluser]kiga[/eluser]
i try to change the validation to form_validation
Code:
// validation fields
    function _set_fields(){
        $fields['id'] = 'id';
        $fields['name'] = 'name';
        $fields['gender'] = 'gender';
        $fields['dob'] = 'dob';
        
        $this->form_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->form_validation->set_rules($rules);
        
        $this->form_validation->set_message('required', '* required');
        $this->form_validation->set_message('isset', '* required');
        $this->form_validation->set_error_delimiters('<p class="error">', '</p>');
    }
    
    // date_validation callback
    function valid_date($str)
    {
        if(!ereg("^(0[1-9]|1[0-9]|2[0-9]|3[01])-(0[1-9]|1[012])-([0-9]{4})$", $str))
        {
            $this->form_validation->set_message('valid_date', 'date format is not valid. dd-mm-yyyy');
            return false;
        }
        else
        {
            return true;
        }
    }

but i still have something wrong


( ! ) Fatal error: Call to undefined method CI_Form_validation::_set_fields() in C:\wamp\www\CodeIgniter\application\controllers\person.php on line 177
Call Stack
# Time Memory Function Location
1 0.0933 386312 {main}( ) ..\index.php:0
2 0.6529 454800 require_once( 'C:\wamp\www\CodeIgniter\system\core\CodeIgniter.php' ) ..\index.php:201
3 1.1664 3229184 call_user_func_array ( ) ..\CodeIgniter.php:339
4 1.1664 3229232 Person->add( ) ..\CodeIgniter.php:0
5 1.1664 3229232 Person->_set_fields( ) ..\person.php:57

this is the line

Code:
function add(){
        // set validation properties
        $this->_set_fields();
        
        // set common properties
        $data['title'] = 'Add new person';
        $data['message'] = '';
        $data['action'] = site_url('person/addPerson');
        $data['link_back'] = anchor('person/index/','Back to list of persons',array('class'=>'back'));
    
        // load view
        $this->load->view('personEdit', $data);
    }


Messages In This Thread
new with codeigniter - by El Forum - 04-13-2011, 01:44 PM
new with codeigniter - by El Forum - 04-13-2011, 02:02 PM
new with codeigniter - by El Forum - 04-13-2011, 04:57 PM
new with codeigniter - by El Forum - 04-14-2011, 08:47 AM
new with codeigniter - by El Forum - 04-14-2011, 11:07 AM
new with codeigniter - by El Forum - 04-14-2011, 02:11 PM
new with codeigniter - by El Forum - 04-14-2011, 03:39 PM
new with codeigniter - by El Forum - 04-14-2011, 03:43 PM
new with codeigniter - by El Forum - 04-14-2011, 04:02 PM
new with codeigniter - by El Forum - 04-14-2011, 04:07 PM
new with codeigniter - by El Forum - 04-14-2011, 04:14 PM
new with codeigniter - by El Forum - 04-14-2011, 04:17 PM
new with codeigniter - by El Forum - 04-14-2011, 04:29 PM
new with codeigniter - by El Forum - 04-14-2011, 04:43 PM
new with codeigniter - by El Forum - 04-14-2011, 04:55 PM
new with codeigniter - by El Forum - 04-14-2011, 06:43 PM
new with codeigniter - by El Forum - 04-14-2011, 08:52 PM
new with codeigniter - by El Forum - 04-15-2011, 12:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB