mirror of
https://github.com/django/django.git
synced 2025-08-27 05:54:28 +00:00
Fixed #31073 -- Prevented CheckboxInput.get_context() from mutating attrs.
This commit is contained in:
parent
3fb7c12158
commit
02eff7ef60
3 changed files with 17 additions and 3 deletions
|
@ -1103,6 +1103,17 @@ class TestSplitFormWidget(PostgreSQLWidgetTestCase):
|
|||
}
|
||||
)
|
||||
|
||||
def test_checkbox_get_context_attrs(self):
|
||||
context = SplitArrayWidget(
|
||||
forms.CheckboxInput(),
|
||||
size=2,
|
||||
).get_context('name', [True, False])
|
||||
self.assertEqual(context['widget']['value'], '[True, False]')
|
||||
self.assertEqual(
|
||||
[subwidget['attrs'] for subwidget in context['widget']['subwidgets']],
|
||||
[{'checked': True}, {}]
|
||||
)
|
||||
|
||||
def test_render(self):
|
||||
self.check_html(
|
||||
SplitArrayWidget(forms.TextInput(), size=2), 'array', None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue