#31073: SplitArrayField with BooleanField always has widgets checked after first
True value
-------------------------------------+-------------------------------------
Reporter: Peter Andersen | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 2.2
Severity: Normal | Resolution:
Keywords: SplitArrayField | Triage Stage:
BooleanField ChecboxInput | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Peter Andersen:
Old description:
> When providing a SplitArrayField BooleanField with preexisting data, the
> final_attrs dict is updated to include `'checked': True` after the for
> loop has reached the first `True` value in the initial data array. Once
> this occurs every widget initialized after that defaults to checked even
> though the backing data may be False. This is caused by the CheckboxInput
> widget's `get_context()` modifying the attrs dict passed into it. This
> is the only widget that modifies the attrs dict passed into its
> get_context().
>
> CheckboxInput setting attrs['checked'] to True:
> https://github.com/django/django/blob/master/django/forms/widgets.py#L527
New description:
When providing a SplitArrayField BooleanField with preexisting data, the
final_attrs dict is updated to include `'checked': True` after the for
loop has reached the first `True` value in the initial data array. Once
this occurs every widget initialized after that defaults to checked even
though the backing data may be False. This is caused by the CheckboxInput
widget's `get_context()` modifying the attrs dict passed into it. This is
the only widget that modifies the attrs dict passed into its
get_context().
CheckboxInput setting `attrs['checked']` to True:
https://github.com/django/django/blob/master/django/forms/widgets.py#L527
--
--
Ticket URL: <https://code.djangoproject.com/ticket/31073#comment:1>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/070.f560c709517ae8cb2fdccadc8d4810de%40djangoproject.com.