Hi there!
Has become indebted to . Clumsy will excuse me in English .
It is a question about simultaneous editing of two tables today .
table:animal
id(prymary_key)
animal_id
owner_id
comment
table:owner_detail
owner_id(prymary_key)
owner_name
owner_address
As there were two tables,
and the animal on the table to be set in the grocery CRUD.
You can manage screen you can edit it directly is when the animal of the table,
also owner_detail to the owner_id the search criteria
We would like to be able to edit the management screen.
... I wonder if I do? How can had been considered,
Since the failure message is displayed after editing, it does not seem to work.
It should be noted that the correction screen will safely operate and comment out the owner_name and owner_address of edit_fields.
Also, when you re-edited in the editing screen
There is also the problem that the sky so did not get before the entered value.
//Question Summary
While to get the value of the second table is displayed on the field,
Please professor the flow for a successful editing.
Excuse me is difficult to read and then attach but sample code below.
//Sample code
function animal_example() {
$crud = new grocery_CRUD();
$crud->set_table('animal')
->columns('animal_id','owner_id','comment');
$crud->set_primary_key('id');
$crud->add_fields('owner_name','owner_address');
$crud->edit_fields('comment','owner_name','owner_address');
$crud->change_field_type('animal_id','invisible');
$crud->change_field_type('owner_id','invisible');
$crud->callback_before_update(array($this,'animal_detail_send'));
$output = $crud->render();
$this->load->view('animal_list',$output);
}
function animal_detail_send($post_array){
$data = array(
'owner_name' => $post_array['owner_name'],
'owner_address' => $post_array['owner_address']
);
$this->db->where('owner_id',$post_array['owner_id']);
$this->db->insert('owner_detail',$data);
unset($post_array['owner_name']);
unset($post_array['owner_address']);
return $post_array;
}
Thank you for reading!