Skip to content

Commit cfb28a6

Browse files
committed
remove editReadonly columns from record before BeforeSave hook on edit
1 parent 9fd25f0 commit cfb28a6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

adminforth/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ class AdminForth implements IAdminForth {
385385
{ resource: AdminForthResource, recordId: any, record: any, oldRecord: any, adminUser: AdminUser, extra?: HttpExtra }
386386
): Promise<{ error?: string }> {
387387

388+
// remove editReadonly columns from record
389+
for (const column of resource.columns.filter((col) => col.editReadonly)) {
390+
if (column.name in record)
391+
delete record[column.name];
392+
}
393+
388394
// execute hook if needed
389395
for (const hook of listify(resource.hooks?.edit?.beforeSave)) {
390396
const resp = await hook({
@@ -404,6 +410,7 @@ class AdminForth implements IAdminForth {
404410
return { error: resp.error };
405411
}
406412
}
413+
407414
const newValues = {};
408415
const connector = this.connectors[resource.dataSource];
409416

0 commit comments

Comments
 (0)