⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

unset_columns on joined table fails.



Raboo
  • profile picture
  • Member

Posted 20 June 2012 - 12:46 PM

Hi,

I have a "$crud->unset_columns('operatingsystem_id');" but yet it is displayed anyway in the list.
operatingsystem_id is a foregin key for operatingsystem table.
os1_id, os2_id, os3_id are duplicate foregin keys for operatingsystem_id in order to display different colums from the operatingsystem table as different colums.

What I want to accomplish is to display os1_id, os2_id, os3_id in the list, but edit operatingsystem_id in the edit.
That works now. But I do not want to display operatingsystem_id in the list. unset_columns doesn't appear to do it's job in this case. Is it a bug?



function _callback_updateos($post_array, $id)
{
$data = array(
'os1_id' => $post_array["operatingsystem_id"],
'os2_id' => $post_array["operatingsystem_id"],
'os3_id' => $post_array["operatingsystem_id"]
);
$this->db->update('node', $data, array('node_id' => $id));
return true;
}

function node()
{
try{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('node');
$crud->set_subject('Nodelist');
$crud->display_as('customer_id','Customer')
->display_as('operatingsystem_id','OS')
->display_as('service_window_id','Service Window')
->display_as('nodegroup_id','Node Group')
->display_as('adminteam_id','Admin Team')
->display_as('contact_person_id','Owner')
->display_as('ipaddress','IP Address')
->display_as('pwmgmt','Password Management')
->display_as('lastpatch','Last Patched')
->display_as('patchingtype','Patch Type')
->display_as('startroutine','Start Routines')
->display_as('stoproutine','Stop Routines')
->display_as('os1_id','OS')
->display_as('os2_id','OS Version')
->display_as('os3_id','End Of Life');
$crud->required_fields('name');
$crud->set_relation('customer_id','customer','name');
$crud->set_relation('operatingsystem_id','operatingsystem','{name} {version} {servicepack}');
$crud->set_relation('service_window_id','service_window','name');
$crud->set_relation('nodegroup_id','nodegroup','name');
$crud->set_relation('adminteam_id','adminteam','name');
$crud->set_relation('contact_person_id','contact_person','name');
$crud->set_relation('os1_id','operatingsystem','name');
$crud->set_relation('os2_id','operatingsystem','{version} {servicepack}');
$crud->set_relation('os3_id','operatingsystem','endoflife');
$crud->unset_fields('os1_id','os2_id','os3_id');
$crud->unset_columns('operatingsystem_id');
$crud->unset_texteditor('comments','startroutine','stoproutine');
$crud->callback_column($this->unique_field_name('service_window_id'),array($this,'_callback_servicewindow'));
$crud->callback_column($this->unique_field_name('customer_id'),array($this,'_callback_customer'));
$crud->callback_after_insert(array($this, '_callback_updateos'));
$crud->callback_after_update(array($this, '_callback_updateos'));

$output = $crud->render();
$this->_example_output($output);

}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}

jean-baptiste
  • profile picture
  • Member

Posted 05 February 2013 - 10:40 AM

Hello,

I also reproduced the problem.


davidoster
  • profile picture
  • Member

Posted 07 February 2013 - 04:46 AM

Try to use this to set the columns that you need to be displayed instead,

http://www.grocerycrud.com/documentation/options_functions/columns