You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 7.x/crud-save-actions.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,23 +5,25 @@
5
5
<aname="about"></a>
6
6
## About
7
7
8
-
`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.
8
+
`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.
9
9
10
10
<aname="defaults"></a>
11
11
## Default Save Actions
12
12
13
13
There are four save actions registered by Backpack by default. They are:
14
-
-```save_and_back``` (Save your entity and go back to previous URL)
15
-
-```save_and_edit``` (Save and edit the current entry)
16
-
-```save_and_new``` (Save and go to create new entity page)
17
-
-```save_and_preview``` (Save and go to show the current entity)
14
+
-`save_and_back` (Save your entity and go back to previous URL)
15
+
-`save_and_edit` (Save and edit the current entry)
16
+
-`save_and_new` (Save and go to create new entity page)
17
+
-`save_and_preview` (Save and go to show the current entity)
18
+
19
+
> **Note:** The `save_and_preview` action is only visible if the `show` operation is enabled for the entity.
18
20
19
21
<aname="save-action-classes"></a>
20
22
## Save Action Classes
21
23
22
24
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:
23
25
- any call will only occupy one line in your CrudController (instead of 10);
24
-
- you can easily re-use that saveaction in other CrudControllers;
26
+
- you can easily re-use that save action in other CrudControllers;
25
27
26
28
Backpack ships with a few save action classes itself:
27
29
-`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
117
119
118
120
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:
119
121
120
-
#### addSaveAction(array $saveAction)
122
+
#### addSaveAction($saveAction)
121
123
122
-
Adds a new SaveAction to the "Save" button/dropdown.
124
+
Adds a new save action to the "Save" button/dropdown.
123
125
124
126
```php
125
127
// using save action classes
@@ -182,7 +184,7 @@ CRUD::addSaveActions([
182
184
This allows you to replace the current save actions with the ones provided in an array.
0 commit comments