⚠ 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

how to unset column



seth

seth
  • profile picture
  • Member

Posted 04 April 2017 - 11:45 AM

hi crud masters

 

$crud->unset_columns('empNumber');

 

i have a table which is related to another table for the faculty lists

 

I would like to not show the faculty column in the output / data grid view.

 

though i have already used the crud unset function it and and hidden as well the field in the callback function but doesn't seem to work out.

 

please help

 


xheradon

xheradon
  • profile picture
  • Member

Posted 04 April 2017 - 13:31 PM

Well, there is a 'bug' when you unset a column which has any relationship with another table. To avoid this, my fix was to set relationship only when I need. I mean, if I only want this field on add form, just set

if ($crud->getState() == 'add') {
    // do relationship
}

So, if I am on read state it won't be any relationship so I could unset the column.