]> _ Git - cubist_cms-back.git/commitdiff
wip #4666 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Oct 2021 11:50:10 +0000 (13:50 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Oct 2021 11:50:10 +0000 (13:50 +0200)
src/app/Magic/Controllers/CubistMagicController.php

index 5d8f03c5087f45f56d8c3da0f7ff150879eec31f..02b8f903e7fcff93f606f7042b592ae7eb7ee495 100644 (file)
@@ -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);
         }