#29273: MultipleChoiceField auto selects on initial load the empty value
--------------------------------------------+------------------------
               Reporter:  Tim Kleinschmidt  |          Owner:  nobody
                   Type:  Uncategorized     |         Status:  new
              Component:  Forms             |        Version:  1.11
               Severity:  Normal            |       Keywords:
           Triage Stage:  Unreviewed        |      Has patch:  0
    Needs documentation:  0                 |    Needs tests:  0
Patch needs improvement:  0                 |  Easy pickings:  0
                  UI/UX:  0                 |
--------------------------------------------+------------------------
 hi,

 I upgraded Django from 1.8 to 1.11, in the last month and we have now a
 bug that the empty choice is always selected on initial page load and
 leads to confusion. If I deselect and select the value it work like
 intended.

 It seems for me that there is no
 [https://github.com/django/django/blob/1.11.11/django/forms/widgets.py#L591
 check] if something was already selected or if it be a fresh form. Like it
 was in
 [https://github.com/django/django/blob/1.8.19/django/forms/widgets.py#L523
 1.8] in `selected_choices`

 I think this report also apply to the `ModelMultipleChoiceField`



 e.g.
 {{{
 #!div style="font-size: 80%"
 Code highlighting:
   {{{#!python
   choices = [(u'', '(no extra)'), (u'cheese', u'Cheese'), (u'Pepper',
 u'Pepper')]
   extra_topics = forms.MultipleChoiceField(required=False,
 choices=choices)
   }}}
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29273>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.15b356c8a65681f474b2433439e3a31d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to