BelongsToMany relation not fully respect policy rules in attach #6384
Replies: 5 comments
-
@crynobone any news? Maybe you need more info? |
Beta Was this translation helpful? Give feedback.
-
This feel a chicken vs egg scenario. Policy is not able to predict that adding 2 new records is not allowed. It can only check if we attempting to create a record. |
Beta Was this translation helpful? Give feedback.
-
But why policy don't check conditions AFTER i press the Attach button? In my opinion, this is two separate scenarios:
For now only first scenario works. |
Beta Was this translation helpful? Give feedback.
-
As I said earlier, during button press it can only get the policy for current process and cannot predict if it can add another. Showing 403 as suggested above is not the ideal solution (possibly making the UX worst) |
Beta Was this translation helpful? Give feedback.
-
Understand. But current behavior is not ideal too - you have policy with some restrictions, but if user open attach screen - it completely not working. My workaround now - use model creating callback, but this is bit ugly. Hope you can do something with this in your way! |
Beta Was this translation helpful? Give feedback.
-
Description:
I found a (possible) bug in the way
BelongsToMany
works. In the policy I created a condition likeIt works, the Attach button disappears if it is exceeded limit of 6.
However, if you use the Attach & Attach Another functionality, then the policy does not work and you can add it endlessly.
Detailed steps to reproduce the issue on a fresh Nova installation:
BelongsToMany
relation fieldExpected Behavior
When clicking Attach & Attach Another - the policy checks the conditions and returns 403 if policy return false
Beta Was this translation helpful? Give feedback.
All reactions