-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
MultipleChooserPanel should not allow selecting duplicate objects #10496
Comments
Thanks for the suggestion @pySilver! This isn't something that we'd want to "bake in" to MultipleChooserPanel, since we don't want it to be limited to plain many-to-many relations - it needs to cover cases such as a slideshow where each slide is an image plus caption, and choosing an image once should not prevent using it again (with another caption). I suppose the neatest approach here would be for MultipleChooserPanel to recognise when the inline child model has a |
Good point. State issues :) What about passing the selection state back to the modal every time it's requested and handle unique optional requirement there. |
I am also facing this issue, and ask if there is some known way to pass in a QS of options into the MultipleChooserPanel so that the choices in the modal are limited with some logic, either by unique to what's already saved in the model, or some other logic. |
It seems that currently the most sane solution would be to get the reffer header from the request, and use that to reverse the url, get the object which is being edited, and then filter the QS based on that. IT doesn't include the current form state, but works well when adding a extra item to a unique list, as it'll only show valid non-duplciate rows. |
The referer header is not reliable - browsers often block it for privacy reasons. However, passing a list of currently-selected object IDs to the chooser is not really the hard part - the hard part is keeping track of the currently selected items while navigating through the chooser. |
Meaning: the current state of the model Form? or The currently edited object ID, is hard to track when navigating? Even having the currently edited object in the request, would be a massive improvement. |
Issue Summary
it looks like
MultipleChooserPanel
allows selecting the same objects when accessed multiple times. Yes, it shows an appropriate error message on save but such behavior should not be possible in the first place or at least configurable.The text was updated successfully, but these errors were encountered: