Fixed #36829 -- Reverted value of ClearableFileInput.use_fieldset to True.

There was unresolved discussion regarding whether to set
ClearableFileInput.use_fieldset to True or False when use_fieldset was
introduced in Django 4.1, since the clear checkbox appears only
sometimes. Although using <fieldset> is likely desirable, since the
primary motivation in #35892 was just to improve markup in the admin,
and a deprecation path was not provided for general form usage, future
work is deferred to #36828.

Regression in 4187da258f.

Thanks Tim Graham, Antoliny, and David Smith for triage.
This commit is contained in:
Johannes Maron
2025-12-27 12:28:26 +01:00
committed by Jacob Walls
parent c496a7df64
commit 79ab0993d0
4 changed files with 13 additions and 9 deletions

View File

@@ -246,19 +246,18 @@ class ClearableFileInputTest(WidgetTest):
)
form = TestForm()
self.assertIs(self.widget.use_fieldset, True)
self.assertIs(self.widget.use_fieldset, False)
self.assertHTMLEqual(
"<div><fieldset><legend>Field:</legend>"
'<input id="id_field" name="field" type="file" required></fieldset></div>'
"<div><fieldset><legend>With file:</legend>Currently: "
'<div><label for="id_field">Field:</label>'
'<input id="id_field" name="field" type="file" required></div>'
'<div><label for="id_with_file">With file:</label>Currently: '
'<a href="something">something</a><br>Change:<input type="file" '
'name="with_file" id="id_with_file"></fieldset></div>'
"<div><fieldset><legend>Clearable file:</legend>"
'name="with_file" id="id_with_file"></div>'
'<div><label for="id_clearable_file">Clearable file:</label>'
'Currently: <a href="something">something</a><input '
'type="checkbox" name="clearable_file-clear" id="clearable_file-clear_id">'
'<label for="clearable_file-clear_id">Clear</label><br>Change:'
'<input type="file" name="clearable_file" id="id_clearable_file">'
"</fieldset></div>",
'<input type="file" name="clearable_file" id="id_clearable_file"></div>',
form.render(),
)