Skip to content

Commit 0d1eb12

Browse files
ViktorBojdaViktor Bojda
andauthored
fix: set form_field's widget id to be the same as context's widget id (#68)
* fix: set form_field's widget id to be the same as context's widget id Needed for BoundField.id_for_label to work correctly. * triv: bump version * triv: set widget attr directly --------- Co-authored-by: Viktor Bojda <[email protected]>
1 parent 9017621 commit 0d1eb12

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-smartbase-admin"
3-
version = "1.0.12"
3+
version = "1.0.13"
44
description = ""
55
authors = ["SmartBase <[email protected]>"]
66
readme = "README.md"

src/django_smartbase_admin/admin/widgets.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ def get_context(self, name, value, attrs):
8282
)
8383
except:
8484
pass
85-
context["widget"]["attrs"][
86-
"id"
87-
] = f"{modal_prefix}{opts.app_label}_{opts.model_name}_{context['widget']['attrs']['id']}"
85+
widget_id = f"{modal_prefix}{opts.app_label}_{opts.model_name}_{context['widget']['attrs']['id']}"
86+
context["widget"]["attrs"]["id"] = widget_id
87+
# needed for BoundField.id_for_label to work correctly
88+
self.attrs["id"] = widget_id
8889
return context
8990

9091

0 commit comments

Comments
 (0)