Abdo Rabah
Abdo Rabah

Reputation: 2072

How to delete or hide the 'Add' button from the 'Top' stack in backpack Laravel?

I want to hide the button Add button from the Top stack ? i tried $this->crud->removeButton('create'); and $this->crud->removeButtonFromStack('create', 'top'); but it's not working. I don’t want to use $this->crud->denyAccess('create'); because this will cause me a problem when i'm updating. How can i hide the button?

Upvotes: 0

Views: 2115

Answers (3)

Davide Mancuso
Davide Mancuso

Reputation: 384

You can also remove the add a new record button by using

protected function setupListOperation()
{
    // Other code
    CRUD::removeButton('create');
    // Other code
}

This solution was successfully tested in BackPack for Laravel v.6.

Upvotes: 0

Chimaobi Ezeobidi
Chimaobi Ezeobidi

Reputation: 61

Use this method

$this->crud->denyAccess('create') or if it's more than two buttons make it an array i.e

$this->crud->denyAccess(['create', 'update', 'delete']);

Note: Everything should be inside your setup() i.e where your model is been registered

Upvotes: 1

Abdo Rabah
Abdo Rabah

Reputation: 2072

I found the solution. I was adding $this->crud->removeButton('create') in setup() instead of setupListOperation().

Upvotes: 1

Related Questions