From 648b1affc3941ee588d0e74665163b12bcd05bce Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 5 Oct 2021 13:50:10 +0200 Subject: [PATCH] wip #4666 @0.5 --- .../Controllers/CubistMagicController.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/app/Magic/Controllers/CubistMagicController.php b/src/app/Magic/Controllers/CubistMagicController.php index 5d8f03c..02b8f90 100644 --- a/src/app/Magic/Controllers/CubistMagicController.php +++ b/src/app/Magic/Controllers/CubistMagicController.php @@ -102,6 +102,30 @@ class CubistMagicController extends CubistCrudController if ($this->_oneInstance) { $this->crud->removeSaveAction('save_and_back'); $this->crud->removeSaveAction('save_and_new'); + $this->crud->removeSaveAction('save_and_edit'); + $this->crud->addSaveAction([ + 'name' => 'save_and_edit', + 'visible' => function ($crud) { + return $crud->hasAccess('update'); + }, + 'redirect' => function ($crud, $request, $itemId = null) { + $itemId = 1; + $redirectUrl = $crud->route . '/' . $itemId . '/edit'; + if ($request->has('locale')) { + $redirectUrl .= '?locale=' . $request->input('locale'); + } + if ($request->has('current_tab')) { + $redirectUrl = $redirectUrl . '#' . $request->get('current_tab'); + } + + return $redirectUrl; + }, + 'referrer_url' => function ($crud, $request, $itemId) { + $itemId = 1; + return url($crud->route . '/' . $itemId . '/edit'); + }, + 'button_text' => __('Save'), + ],); } $instance->setupSaveActions($this, $type); } -- 2.39.5