Opened 2 years ago
Closed 2 years ago
#33857 closed Bug (invalid)
using FilteredSelectMultiple widget on forms.ModelMultipleChoiceField is not working
Reported by: | Sebastian Rossi | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 2.2 |
Severity: | Normal | Keywords: | forms, widgets, ManytoMany, ModelMultipleChoiceField |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hello there,
I have a form which has a ModelMultipleChoiceField in it, that works correctly, but when i try to add the FilteredSelectMultiple widget from the admin widgets somehow the selected values are no longer in the payload of the POST request
Here is the piece of code for the form field
class Media: css = { 'all': ('/static/admin/css/widgets.css',), } js = ('/admin/jsi18n',) dental_codes = forms.ModelMultipleChoiceField( label='Select Proccedure Codes', queryset = CDTADACodes.objects.all(), widget = FilteredSelectMultiple('Dental Codes Selection', is_stacked=True), required = False )
Here is the html template
<div class="row justify-content-md-center"> <div class="form-group"> {{form.media}} {{form.dental_codes.errors}} {{form.dental_codes}} </div> </div>
Template is correctly loaded in Front End but no values are selected when used. Only by commenting the widget assignment sentence the code works correctly.
Any help is welcomed, thanks in advance
It works for me in the admin, so it's probably an issue in your code. I used the following form:
Moreover Django 2.2 is not supported anymore, you can try to use Django 4.0+.
See TicketClosingReasons/UseSupportChannels for ways to get help.