setActionButtonMultiple
setActionButtonMultiple(string $label, string $cssClassIcon, string $url[, boolean $newTab[, string $idFieldQueryName[, string $querySeparator]]])
setActionButtonMultiple
is used when we need to add extra action buttons for multiple selections on the datagrid.
The functionality is simple, and it takes the below arguments:
label
is the label that the button will have. For example "Photos"cssClassIcon
is css that the icon at the left will have. You can use the default CSS from font-awesome but you can also use your own. For example "fa fa-image"$url
is the URL that is used for the batch action. Please keep in mind that we also send the ids as a query parameter array (e.g. ?id[]=2&id[]=5)$newTab
: if the URL will open in a new tab. Default:false
$idFieldQueryName
is used when we would like to change the name of the on the query parameters. Default:id
$querySeparator
is used when we would like to change the query separator. It is most commonly used when we already have a URL parameter in our URL.
You can see a basic example of the setActionButtonMultiple below:
$url = 'https://example.com/view_avatar';
$crud->setActionButtonMultiple('Avatar', 'fa fa-user', $url, true);
A full working example can be found below:
$crud->setTable('employees');
$crud->setSubject('Employee', 'Employees');
$crud->setRelation('officeCode','offices','city');
$crud->displayAs('officeCode','City');
$crud->unsetEdit();
// For demo purposes we are using the # so we will not have a new URL redirection
$crud->setActionButtonMultiple('Avatar', 'fa fa-user', '#/avatar/');
// Although this is not required, it is better for a usability perspective to
// also include the button for a single use
$crud->setActionButton('Avatar', 'fa fa-user', function ($row) {
return '#/avatar/' . $row->employeeNumber;
}, false);
You can see the result of the above code here. In order to check the functionality you will need to select any number of rows from the checkboxes on the left