Skip to content

Commit 97d1b45

Browse files
committed
fix: prevent 'restricted from creation' error
1 parent 7d809c6 commit 97d1b45

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ export default class ForeignInlineListPlugin extends AdminForthPlugin {
4141
}
4242

4343
const { allowedActions } = await interpretResource(adminUser, resourceCopy, {}, ActionCheckSource.DisplayButtons, this.adminforth);
44+
// if inline table has create action
45+
// check if foreign resource allows for its corresponding foreign resource column to be set on create
46+
if (allowedActions.create) {
47+
for (const column of resource.columns) {
48+
if (column.foreignResource?.resourceId === this.resourceConfig.resourceId && !column.showIn.create) {
49+
return { error: `Resource ${this.options.foreignResourceId} column ${column.name} should be editable on create page for inline list in ${this.resourceConfig.resourceId} resource to work` };
50+
}
51+
}
52+
}
4453

4554
return {
4655
resource: {

0 commit comments

Comments
 (0)