$this->grocery_crud->set_table('tb2');
[...]
$this->grocery_crud->fields('tbl1.column1, tbl2.column1, tbl2.column2'); //Put the names of the fields
$this->grocery_crud->callback_edit_field('tbl1.column1', array($this, '_callback_edit_tb1_column1')) ;
$this->grocery_crud->callback_before_update(array($this, '_callback_before_update'));
$this->grocery_crud->callback_after_update(array($this, '_callback_after_update'));
[...]
$this->grocery_crud->render();
[...]
}
//The callback edit function will return your input
//I made an example with a select, but you could just return an input
function _callback_edit_tb1_column1($value, $primary_key) {
$input = '<select id="tb1.column" name="tb1.column">' //(the name attribute must be the same of your field)
$results = $this->TB1_model->findAll(); //find the data you want
if ($results) {
foreach ($results as $data) {
$input .= '<option value="' . $data->id . '">' . $data->description . '</option>'
}
}
$input .= '</select>';
return $input;
}
//callback_before_update
_callback_before_update($post_array, $primary_key) {
$this->session->set_userdata('your_TB1_field_name', $post_array['your_TB1_field_name']);
unset($post_array['your_TB1_field_name']);
return $post_array;
}
//callback_after_update
_callback_after_update($post_array, $primary_key) {
$field_value = $this->session->userdata('your_field_name');
if ($field_value) {
$this->db->where('tb2_column1', $primary_key);
$this->db->update('tb1', array('tb1.column' => $field_value));
$this->session->unset_userdata('your_field_name');
}
}
Hi! I did something like that in my case.. That's just a small example for you to have an idea of the thing..
I don't know if that's your case, but I hope it helps.
PS.: I'm not on my own computer, so I did not test this, but I think you'll be able to start from there..
=]