1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #34119 -- Prevented callable default hidden widget value from being overridden.

Thanks to Benjamin Rigaud for the report.
This commit is contained in:
David Sanders
2022-10-26 19:05:27 +11:00
committed by Mariusz Felisiak
parent 04b15022e8
commit 25904db915
2 changed files with 49 additions and 1 deletions

View File

@@ -96,9 +96,17 @@ class BoundField:
attrs.setdefault(
"id", self.html_initial_id if only_initial else self.auto_id
)
if only_initial and self.html_initial_name in self.form.data:
# Propagate the hidden initial value.
value = self.form._widget_data_value(
self.field.hidden_widget(),
self.html_initial_name,
)
else:
value = self.value()
return widget.render(
name=self.html_initial_name if only_initial else self.html_name,
value=self.value(),
value=value,
attrs=attrs,
renderer=self.form.renderer,
)