Enable Action Dropdown with Custom Buttons Only (No Default Buttons) #1392
Replies: 2 comments
-
Yes, you can enable the action buttons dropdown in Backpack and have it display only your custom buttons, with all default buttons (show, edit, delete) removed. The dropdown UI/UX is not tied to the presence of default buttons—it is controlled by the lineButtonsAsDropdown setting, which applies to all buttons in the line stack, whether default or custom. Here’s how you can achieve your desired setup:
This will result in only your custom buttons being present in the dropdown. The dropdown functionality is not dependent on the presence of default buttons; it simply groups whatever buttons are present in the line stack into a dropdown, according to your configuration. References:
There is no mention in the knowledge sources of a requirement for default buttons to be present for the dropdown to work. If you encounter issues, ensure you are using the correct Backpack version and that your custom buttons are properly added to the line stack. ℹ️ Please note our AI Bot does not reply to follow-ups, this will be the only AI answer in this thread. If the AI helped you find the answer, please mark it as answered or write details below so it can learn. Then close the conversation. If not, please give more information for when a human reads this. ℹ️ Relevant sources: Save Actions|Save Actions API |
Beta Was this translation helpful? Give feedback.
-
Update: Attempted Solution Still Not WorkingI tried implementing the suggested approach using the Here's my current implementation: public function setup()
{
CRUD::setModel(VehicleInstance::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/vehicle');
CRUD::setEntityNameStrings('vehicle', 'vehicles');
$this->crud->denyAccess(['create', 'delete']);
/**
* Configuration pour convertir les boutons en dropdown
*/
$this->crud->operation('list', function () {
$this->crud->enableBulkActions();
// Activer la conversion automatique des boutons en dropdown
CRUD::setOperationSetting('lineButtonsAsDropdown', true);
CRUD::setOperationSetting('lineButtonsAsDropdownMinimum', 0);
// Ajouter les boutons individuels qui seront automatiquement convertis en dropdown
// Bouton "Modifier" personnalisé
CRUD::button('update_custom')->stack('line')->view('crud::buttons.link_button')->meta([
'access' => 'update',
'label' => trans('backpack::crud.edit'),
'icon' => 'la la-edit',
'icon_size' => 'la-lg',
'color' => 'text-primary',
'title' => trans('backpack::crud.edit'),
'url' => function ($entry, $crud) {
return url($crud->route . '/' . $entry->getKey() . '/edit');
}
]);
// Bouton "Voir le véhicule"
CRUD::button('vehicle_show')->stack('line')->view('crud::buttons.link_button')->meta([
'access' => true,
'label' => 'Voir le véhicule',
'icon' => 'la la-external-link',
'icon_size' => 'la-lg',
'color' => 'text-success',
'target' => '_blank',
'title' => 'Voir le véhicule sur le site',
'divider_after' => true,
'url' => function ($entry, $crud) {
return $entry->url;
}
]);
// Bouton "Imprimer la fiche"
CRUD::button('printAttach')->stack('line')->view('crud::buttons.link_button')->meta([
'access' => 'show',
'label' => 'Imprimer la fiche',
'icon' => 'la la-print',
'icon_size' => 'la-lg',
'color' => 'text-info',
'target' => '_blank',
'title' => 'Imprimer la fiche véhicule',
'url' => function ($entry, $crud) {
return url($crud->route . '/' . $entry->getKey() . '/print-attach');
}
]);
// Bouton "Force-reload"
CRUD::button('printAttachForce')->stack('line')->view('crud::buttons.link_button')->meta([
'access' => 'show',
'label' => 'Force-reload',
'icon' => 'la la-sync',
'icon_size' => 'la-lg',
'color' => 'text-warning',
'target' => '_blank',
'title' => 'Imprimer la fiche véhicule (forcer le rechargement)',
'url' => function ($entry, $crud) {
return url($crud->route . '/' . $entry->getKey() . '/print-attach?force=true');
}
]);
$this->crud->addButtonFromView('bottom', 'bulk_printAttach', 'vehicles.printing.bulkPrintAttach', 'beginning');
// Supprimer tous les boutons par défaut
$this->crud->removeButton('delete');
$this->crud->removeButton('update');
$this->crud->removeButton('show');
});
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Feature Request: Enable Action Dropdown with Custom Buttons Only (No Default Buttons)
Is your feature request related to a problem? Please describe.
Currently, when using the action buttons dropdown functionality in Backpack's operation lists, it's not possible to have a dropdown containing only custom buttons without displaying any of the default buttons (show/edit/delete).
The current implementation seems to require at least one default button to be visible to enable the dropdown functionality, which limits customization flexibility when we want to provide entirely custom actions.
Describe the solution you'd like
I would like the ability to:
Example use case:
Beta Was this translation helpful? Give feedback.
All reactions