unsetAddFields

unsetAddFields(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 unsetAddFields is doing just that. This function is really useful especially when the development of the database is on going. The syntax is simple:

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

You can see a full working example below:

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

$output = $crud->render();

As you can also see by your own at the below live example, in every area all the fields/columns are visible expect the ones at the add form modal. More specifically you will notice that the fields "salesRepEmployeeNumber" and "creditLimit" are missing when you press "Add Customer":