Skip to content

Commit ebe1c8d

Browse files
committed
docs for save and preview
1 parent b55ac24 commit ebe1c8d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

7.x/crud-save-actions.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,25 @@
55
<a name="about"></a>
66
## About
77

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.
99

1010
<a name="defaults"></a>
1111
## Default Save Actions
1212

1313
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.
1820
1921
<a name="save-action-classes"></a>
2022
## Save Action Classes
2123

2224
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:
2325
- 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;
2527

2628
Backpack ships with a few save action classes itself:
2729
- `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
117119

118120
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:
119121

120-
#### addSaveAction(array $saveAction)
122+
#### addSaveAction($saveAction)
121123

122-
Adds a new SaveAction to the "Save" button/dropdown.
124+
Adds a new save action to the "Save" button/dropdown.
123125

124126
```php
125127
// using save action classes
@@ -182,7 +184,7 @@ CRUD::addSaveActions([
182184
This allows you to replace the current save actions with the ones provided in an array.
183185

184186
```php
185-
CRUD::replaceSaveActions(
187+
CRUD::replaceSaveActions([
186188
[
187189
'name' => 'save_action_one',
188190
'visible' => function($crud) {
@@ -192,7 +194,7 @@ CRUD::replaceSaveActions(
192194
return $crud->route;
193195
},
194196
],
195-
);
197+
]);
196198
```
197199

198200

0 commit comments

Comments
 (0)