Skip to content

Commit

Permalink
Fixes #13064: Ensure unchecked checkboxes do not revert to original v…
Browse files Browse the repository at this point in the history
…alues upon HTMX form refresh
  • Loading branch information
jeremystretch committed Oct 3, 2023
1 parent 6093deb commit 4bbb4d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions netbox/netbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def _setting(name, default=None):
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.forms',
'corsheaders',
'debug_toolbar',
'graphiql_debug_toolbar',
Expand Down Expand Up @@ -430,6 +431,9 @@ def _setting(name, default=None):
},
]

# This allows us to override Django's stock form widget templates
FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'

# Set up authentication backends
if type(REMOTE_AUTH_BACKEND) not in (list, tuple):
REMOTE_AUTH_BACKEND = [REMOTE_AUTH_BACKEND]
Expand Down
6 changes: 6 additions & 0 deletions netbox/templates/django/forms/widgets/checkbox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% comment %}
Include a hidden field of the same name to ensure that unchecked checkboxes
are always included in the submitted form data.
{% endcomment %}
<input type="hidden" name="{{ widget.name }}" value="">
{% include "django/forms/widgets/input.html" %}

0 comments on commit 4bbb4d9

Please sign in to comment.