unsetCloneFields
unsetCloneFields(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 unsetCloneFields
is doing just that! This function is really useful especially when the development of the database is ongoing. The syntax is simple:
$crud->unsetCloneFields(['address_1', 'address_2', 'credit_limit']);
You can see a full working example below:
$crud->setTable('customers');
$crud->setSubject('Customer', 'Customers');
$crud->setClone();
$crud->unsetCloneFields(['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 Clone form modal. More specifically you will notice that the fields salesRepEmployeeNumber
and creditLimit
are missing when you press "Clone Customer" in any row: