Skip to content

fix: prevent 'restricted from creation' error #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ export default class ForeignInlineListPlugin extends AdminForthPlugin {
}

const { allowedActions } = await interpretResource(adminUser, resourceCopy, {}, ActionCheckSource.DisplayButtons, this.adminforth);
// if inline table has create action
// check if foreign resource allows for its corresponding foreign resource column to be set on create
if (allowedActions.create) {
for (const column of resource.columns) {
if (column.foreignResource?.resourceId === this.resourceConfig.resourceId && !column.showIn.create) {
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` };
}
}
}

return {
resource: {
Expand Down