unsetFields(array $fields)

There are cases that we have lots of fields and we just need to say "I need all of them expect these 3". Well unsetFields is doing just that! This function is really useful especially when the development of the database is on going. The unsetFields is removing the fields on add/edit and view form modal. Have in mind that it is not removing any columns. If you need to do the same but for columns, you should use the method unsetColumns instead

The syntax is simple:

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

The above code is equivalent (e.g. a shortcut) to:

$crud->unsetAddFields(['address_1', 'address_2', 'credit_limit']);
$crud->unsetEditFields(['address_1', 'address_2', 'credit_limit']);
$crud->unsetCloneFields(['address_1', 'address_2', 'credit_limit']);
$crud->unsetReadFields(['address_1', 'address_2', 'credit_limit']);

You can see a full working example below:

$crud->setSubject('Customer', 'Customers');

$output = $crud->render();

As you can also see by your own at the below live example, at the add/edit/view form modal all the fields are there expect the one that we have at the unsetFields. More specifically you will notice that the fields "salesRepEmployeeNumber" and "creditLimit" are missing when you press "Add Customer" or "Edit Customer", "View Customer" in any row: