unsetClone

unsetClone(void)

The method unsetClone is removing completely the Clone operation for the end-user. More specifically:

  1. It is removing the button "Clone" from the datagrid
  2. The user doesn't have the ability to Clone any data even if they try to do it by having the URL of the API (e.g. the permission is not allowed)

The syntax is simple. You can find an example below:

$crud->unsetClone();

Important notice: As you probably already noticed, the operation clone is removed by default. So this function is probably more rare to be used. However a usage of the unsetClone is in case you need to have role based data in your admin. For example:

$crud->setTable('customers');
$crud->setSubject('Customer', 'Customers');
$crud->columns(['customerName','phone','addressLine1','creditLimit']);
$crud->setClone();

// This will probably be in a different method but for now we are
// keeping it simple to understand the example
if (user_not_allowed_for_clone()) {
    $crud->unsetClone();
}

$output = $crud->render();

Example

Below we have an example of setting and then right after unsetting the clone just to see that it will work:

$crud->setTable('customers');
$crud->setSubject('Customer', 'Customers');
$crud->columns(['customerName','phone','addressLine1','creditLimit']);

// It doesn't make much sense to do that but for the sake of the example...
$crud->setClone();
$crud->unsetClone();

$output = $crud->render();

Below you can see the results of the above code: