unsetColumns

unsetColumns(array $fields)

There are cases that we have lots of columns and we just need to say "I need all of them expect those 3". Well unsetColumns is doing just that! This function is really useful especially when the development of the database is on going. The syntax is simple:

$crud->unsetColumns(['address_1', 'address_2', 'credit_limit']);

Example

$crud->setTable('customers');
$crud->setSubject('Customer', 'Customers');
$crud->unsetColumns(['salesRepEmployeeNumber','creditLimit']);

$output = $crud->render();

As you can also see by your own at the below live example, in every other area (add/edit/view form) all the fields are visible. At the datagrid columns however, you can see that all the columns are visible, expect the one that we are unseting. More specifically you will notice that the fields "salesRepEmployeeNumber" and "creditLimit" are missing from the datagrid, however they are available on "Add Customer" or "Edit Customer":