This seems to be an issue with `attrs={'form': 'theform'}` not being
passed through to the underlying checkbox inputs.
SelectMultiple behaves as expected (submitting with the form).
Minimal (inefficient) Example (must be included on a page with a form
named 'theform' to see the problematic POST):
{{{
class UserSelectForm(Form):
selected_users = MultipleChoiceField(
choices=User.objects.all()[0:4],
initial=User.objects.all()[0:4],
widget=SelectMultiple(attrs={'form': 'theform'}),
required=True)
}}}
Not sure if this is fixed in Django>1.8
--
Ticket URL: <https://code.djangoproject.com/ticket/28672>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> This means that POSTing the form does not submit the accompanying
> selected data.
>
> This seems to be an issue with `attrs={'form': 'theform'}` not being
> passed through to the underlying checkbox inputs.
>
> SelectMultiple behaves as expected (submitting with the form).
>
> Minimal (inefficient) Example (must be included on a page with a form
> named 'theform' to see the problematic POST):
>
> {{{
> class UserSelectForm(Form):
> selected_users = MultipleChoiceField(
> choices=User.objects.all()[0:4],
> initial=User.objects.all()[0:4],
> widget=SelectMultiple(attrs={'form': 'theform'}),
> required=True)
> }}}
>
> Not sure if this is fixed in Django>1.8
New description:
This means that POSTing the form does not submit the accompanying selected
data.
This seems to be an issue with `attrs={'form': 'theform'}` not being
passed through to the underlying checkbox inputs.
SelectMultiple behaves as expected (submitting with the form).
Minimal (inefficient) Example (must be included on a page with a form
named 'theform' to see the problematic POST):
{{{
class UserSelectForm(Form):
selected_users = MultipleChoiceField(
choices=[('ex', 'Example'), ('ex2', 'Example2')],
initial='ex',
widget=CheckboxSelectMultiple(attrs={'form':
'theform'}),
required=True)
}}}
Not sure if this is fixed in Django>1.8 as I have found no other reference
to the bug.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/28672#comment:1>
Comment (by Tim Graham):
Please try to confirm bugs on Django master (or at least on the latest
released version) instead of reporting bugs for Django 1.8. Django 1.8
only receives fixes for security and data loss issues at this point.
--
Ticket URL: <https://code.djangoproject.com/ticket/28672#comment:2>
* status: new => closed
* resolution: => worksforme
Comment:
On both Django master and 1.8.x, I see `form="theform"` in the rendered
HTML of both checkbox inputs. Please provide more details (a sample
project would be nice) if you can reproduce your problem with Django
master (or at least 1.11.x or 2.0 alpha).
--
Ticket URL: <https://code.djangoproject.com/ticket/28672#comment:3>
Comment (by Dylan Young):
Hmmm... I'll dig deeper. Maybe this is an issue with crispy-forms that
needs to be submitted.
As for your other note, this is in fact a data loss bug: every bit of data
in that CheckboxSelectMultiple is lost on submit, barring an additional
layer that saves dirty data in the form client-side for recovery.
--
Ticket URL: <https://code.djangoproject.com/ticket/28672#comment:4>
Comment (by Dylan Young):
Confirmed that it's an issue with crispy-forms==1.5.2 and not Django.
Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/28672#comment:5>
* resolution: worksforme => invalid
--
Ticket URL: <https://code.djangoproject.com/ticket/28672#comment:6>