Nested resource - policy for creating parent items in relation manager #19004
Unanswered
countach84
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Package
Actions
Package Version
v5.0.0
How can we help you?
Hello
I have a parent model called Project and a nested model called Task which is displayed as a relation manager on Project edit page. I want to write a policy that allows creating new tasks only when the project status is "draft". If I write a policy like this:
it works if I add the second argument on authorize method on CreateAction
but of course It breaks when one enters the task create form via URL (like /projects/14/tasks/create) because by default the create method accepts/receives only one parameter.
What's the best way to check the project's status and thus allow/disallow the creating of tasks?
I would appreciate any help. Thx!
Beta Was this translation helpful? Give feedback.
All reactions