I’m new to Grocery Crud Enterprise. I’m looking for some help with setActionButton…
In my datagrid, I want to have two action buttons for editing items. The default one (pencil icon) and a custom action . The default button will display a Grocery CRUD edit modal for fields a and b. I want the custom action button to display a Grocery CRUD edit modal for fields c and d.
How would I do this?
With this test code, clicking the ‘Codes’ custom action button for an employee, displays the datagrid for all employees (as defined in the employee_code method). But that’s not what I want. I want to display the Grocery CRUD edit modal for the one employee (as defined in the employee_code method) instead.
public function employee () {
$crud = $this->getGroceryCrudEnterprise();
$crud->setTable(employees);
$crud->setSubject('Employee');
$crud->columns(['First_Name','Last_Name']);
$crud->editFields(['First_Name','Last_Name']);
$crud->setActionButton('Codes', 'fa fa-user-plus', function ($row) {
return '/employee_code#/edit/' . $row->ID;
}, false);
etc...
}
public function employee_code () {
$crud = $this->getGroceryCrudEnterprise();
$crud->setTable(employees);
$crud->setSubject('Employee');
$crud->columns(['First_Name','Last_Name']);
$crud->editFields(['Employee_Number','Tax_File_Number']);
etc...
}
(Why do I want to to do this?
99 times out of 100, the user will edit the basic info on the default edit form. But very occasionally, they will want to edit some complex information. I don’t want this complex information cluttering up the default edit form, so I want to put it on a separate edit form.
This functionality would also be useful where different users have different authority levels. E.g. I’d only set the custom edit button for users with a specific level of authority.)