crudbooster
crudbooster copied to clipboard
Action buttons per row
How can I enable/disable action buttons per row in index (detail,edit,delete)? I know I can create custom action buttons and show them conditionally, but in this case I have to hide default buttons. I set my custom button for edit action and it works fine. But when I make settings like this: ... $this->global_privilege = true; $this->button_edit = false; .... and click on Edit (my custom button), I see message that I have not privilege to edit this resource.
Please help me! Thanks in advance!
try
$this->button_table_action = false
Can the button hide if certain conditions, like the picture above.
If status Open button edit and delete is hide ?
I tried to do it this way:
- Disabling button edit:
$this->button_edit = false;
- Adding an action:
$this->addaction[] = [
'title' => 'Editar', 'url' => CRUDBooster::mainpath('edit/[id]'),
'icon' => 'fa fa-pencil', 'color' => 'success', 'showIf' => '[automatico] == 1'
];
But then editing is disabled for everyone. So, that's not the way.
I "solved" it, by doing this:
- Enable again button edit:
$this->button_edit = true;
- Overriding getEdit():
public function getEdit($id)
{
$comparendo = Comparendo::find($id);
if ($comparendo->automatico == true) {
CRUDBooster::redirectBack(
'Los comparendos <b>electrónicos automáticos</b>, es decir, '
. 'que son generados por este sistema, <b>no se pueden editar</b>.'
);
}
return parent::getEdit($id);
}
You could also try this way with url variables:
$this->button_edit= isset($_GET['variable']) ? false : true;
I tried to do it this way:
- Disabling button edit:
$this->button_edit = false;
- Adding an action:
$this->addaction[] = [ 'title' => 'Editar', 'url' => CRUDBooster::mainpath('edit/[id]'), 'icon' => 'fa fa-pencil', 'color' => 'success', 'showIf' => '[automatico] == 1' ];
But then editing is disabled for everyone. So, that's not the way.
I "solved" it, by doing this:
- Enable again button edit:
$this->button_edit = true;
- Overriding getEdit():
public function getEdit($id) { $comparendo = Comparendo::find($id); if ($comparendo->automatico == true) { CRUDBooster::redirectBack( 'Los comparendos <b>electrónicos automáticos</b>, es decir, ' . 'que son generados por este sistema, <b>no se pueden editar</b>.' ); } return parent::getEdit($id); }
Thank you! this worked great!
I did it in a different way, it just worked for me using query.