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: adminforth/documentation/docs/tutorial/03-Customization/04-hooks.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,21 +27,23 @@ When user opens edit page, AdminForth makes a request to the backend to get the
27
27
28
28

29
29
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.
31
31
32
32
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.
33
33
34
34
## Saving data on edit page
35
35
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.
37
37
38
38

39
39
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
41
43
42
44
## Saving data on create page
43
45
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.
45
47
46
48

47
49
@@ -87,13 +89,13 @@ import type { AdminUser } from 'adminforth';
87
89
}
88
90
```
89
91
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.
91
93
92
94
## List page flow
93
95
94
96
When user opens the list page, AdminForth makes a request to the backend to get the list of items.
95
97
96
-

98
+

97
99
98
100
### Example: limit access in list to user-related records
0 commit comments