Skip to content

Commit 742e879

Browse files
committed
tweak hooks page
1 parent 5553ae8 commit 742e879

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

adminforth/documentation/docs/tutorial/03-Customization/04-hooks.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,23 @@ When user opens edit page, AdminForth makes a request to the backend to get the
2727

2828
![Initial data for edit page flow](image-28.png)
2929

30-
Practically you can use this hook to modify or add some data before it is displayed on the edit page.
30+
Practically you can use `show.afterDatasourceResponse` to modify or add some data before it is displayed on the edit page.
3131

3232
For example [upload plugin](/docs/tutorial/Plugins/upload/) uses this hook to generate signed preview URL so user can see existing uploaded file preview in form, and at the same time database stores only original file path which might be not accessible without presigned URL.
3333

3434
## Saving data on edit page
3535

36-
When user clicks the save button, AdminForth makes a request to the backend to save the data.
36+
When user clicks the "Save" button on edit page, AdminForth makes a request to the backend to save the data.
3737

3838
![Saving data on edit page](image-27.png)
3939

40-
Practically you can use this hook to modify the data or populate new fields before it is saved to the database.
40+
Practically you can use `edit.beforeSave` hook to modify the data or populate new fields before it is saved to the database.
41+
42+
> 👆 Note: according to diagram you should understand that interrupting flow from `edit.afterSave` does not prevent data modification in DB
4143
4244
## Saving data on create page
4345

44-
When user clicks the save button from create page, AdminForth makes a request to the backend to save the data.
46+
When user clicks the "Save" button from create page, AdminForth makes a request to the backend to create new record.
4547

4648
![Saving data on create page](image-26.png)
4749

@@ -87,13 +89,13 @@ import type { AdminUser } from 'adminforth';
8789
}
8890
```
8991

90-
In this way user who creates the apartment will be assigned as a realtor.
92+
In this way user who creates the apartment will be assigned as a realtor. Also user can't set other realtor then himself, even if he will make request using curl/devtools because hook will override the value.
9193

9294
## List page flow
9395

9496
When user opens the list page, AdminForth makes a request to the backend to get the list of items.
9597

96-
![List page flow](image-22.png)
98+
![List page flow](image-31.png)
9799

98100
### Example: limit access in list to user-related records
99101

344 KB
Loading

0 commit comments

Comments
 (0)