Skip to content

Commit 479c6c0

Browse files
committed
fix save actions throw error when all actions removed
1 parent 9a498cd commit 479c6c0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/app/Library/CrudPanel/Traits/SaveActions.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ public function getSaveAction()
275275
//get only the save actions that pass visibility callback
276276
$saveOptions = $this->getVisibleSaveActions();
277277

278+
if (empty($saveOptions)) {
279+
return [];
280+
}
281+
278282
//get the current action
279283
$saveCurrent = $this->getCurrentSaveAction($saveOptions);
280284

@@ -287,7 +291,7 @@ public function getSaveAction()
287291
}
288292

289293
return [
290-
'active' => $saveCurrent,
294+
'active' => $saveCurrent,
291295
'options' => $dropdownOptions,
292296
];
293297
}
@@ -345,8 +349,8 @@ public function performSaveAction($itemId = null)
345349
// if the request is AJAX, return a JSON response
346350
if ($this->getRequest()->ajax()) {
347351
return response()->json([
348-
'success' => true,
349-
'data' => $this->entry,
352+
'success' => true,
353+
'data' => $this->entry,
350354
'redirect_url' => $redirectUrl,
351355
'referrer_url' => $referrer_url ?? false,
352356
]);
@@ -368,7 +372,7 @@ public function setupDefaultSaveActions()
368372
{
369373
$defaultSaveActions = [
370374
[
371-
'name' => 'save_and_back',
375+
'name' => 'save_and_back',
372376
'visible' => function ($crud) {
373377
return $crud->hasAccess('list');
374378
},
@@ -378,7 +382,7 @@ public function setupDefaultSaveActions()
378382
'button_text' => trans('backpack::crud.save_action_save_and_back'),
379383
],
380384
[
381-
'name' => 'save_and_edit',
385+
'name' => 'save_and_edit',
382386
'visible' => function ($crud) {
383387
return $crud->hasAccess('update');
384388
},
@@ -400,7 +404,7 @@ public function setupDefaultSaveActions()
400404
'button_text' => trans('backpack::crud.save_action_save_and_edit'),
401405
],
402406
[
403-
'name' => 'save_and_new',
407+
'name' => 'save_and_new',
404408
'visible' => function ($crud) {
405409
return $crud->hasAccess('create');
406410
},

0 commit comments

Comments
 (0)