From ebe1c8dae021f6dca02f975f817168b26a5d2a5a Mon Sep 17 00:00:00 2001 From: pxpm Date: Tue, 25 Nov 2025 17:48:09 +0000 Subject: [PATCH] docs for save and preview --- 7.x/crud-save-actions.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/7.x/crud-save-actions.md b/7.x/crud-save-actions.md index a412c55e..120de741 100644 --- a/7.x/crud-save-actions.md +++ b/7.x/crud-save-actions.md @@ -5,23 +5,25 @@ ## About -`Create` and `Update` forms end in a Save button with a drop menu. Every option in that dropdown is a SaveAction - they determine where the user is redirected after the saving is complete. +`Create` and `Update` forms end in a Save button with a drop menu. Every option in that dropdown is a save action - they determine where the user is redirected after the saving is complete. ## Default Save Actions There are four save actions registered by Backpack by default. They are: - - ```save_and_back``` (Save your entity and go back to previous URL) - - ```save_and_edit``` (Save and edit the current entry) - - ```save_and_new``` (Save and go to create new entity page) - - ```save_and_preview``` (Save and go to show the current entity) + - `save_and_back` (Save your entity and go back to previous URL) + - `save_and_edit` (Save and edit the current entry) + - `save_and_new` (Save and go to create new entity page) + - `save_and_preview` (Save and go to show the current entity) + +> **Note:** The `save_and_preview` action is only visible if the `show` operation is enabled for the entity. ## Save Action Classes You can define save actions either as simple arrays (inside the API methods) or as classes (starting with Backpack v7). Creating classes for your save actions has multiple benefits: - any call will only occupy one line in your CrudController (instead of 10); -- you can easily re-use that saveaction in other CrudControllers; +- you can easily re-use that save action in other CrudControllers; Backpack ships with a few save action classes itself: - `SaveAndBack`, `SaveAndEdit`, `SaveAndNew` and `SaveAndPreview` are the default; @@ -117,9 +119,9 @@ When no save actions are provided, Backpack falls back to the defaults registere Inside your CrudController, inside your ```setupCreateOperation()``` or ```setupUpdateOperation()``` methods, you can change what save buttons are shown for each operation by using the methods below: -#### addSaveAction(array $saveAction) +#### addSaveAction($saveAction) -Adds a new SaveAction to the "Save" button/dropdown. +Adds a new save action to the "Save" button/dropdown. ```php // using save action classes @@ -182,7 +184,7 @@ CRUD::addSaveActions([ This allows you to replace the current save actions with the ones provided in an array. ```php -CRUD::replaceSaveActions( +CRUD::replaceSaveActions([ [ 'name' => 'save_action_one', 'visible' => function($crud) { @@ -192,7 +194,7 @@ CRUD::replaceSaveActions( return $crud->route; }, ], -); +]); ```