you can use function 'fields' and 'callback before insert'
Hi Victor! Thank you very much!
This problem is ok. My code:
public function user()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('tbl_user');
$crud->columns('username','password');
$crud->fields('username','password','confirmpass')->field_type('password', 'password')->field_type('confirmpass', 'password');
$crud->set_rules('password','Máºt khẩu','required');
$crud->set_rules('confirmpass','Xác nháºn máºt khẩu','matches[password]');
$crud->callback_before_insert(array($this, 'insert_user'));
$output = $crud->render();
$this->Out($output);
}
function insert_user($post_array){
if($post_array['password']==$post_array['confirmpass'])
{
$data = array(
'username' => $post_array['username'] ,
'password' => $post_array['password']
);
$this->db->insert('tbl_user', $data);
//$this->user();
}
}
My application was inserted into the database. But it does not appear message when I click button Save in Add Record form
Or when I click button Save and go back to list. It not redirect to list User (but inserted into database)