False Boolean fields reset to True (or default) when using 'Create and Add Another' or cloning. #6131
Labels
status: accepted
This issue has been accepted for implementation
type: bug
A confirmed report of unexpected behavior in the application
NetBox version
v2.10.8
Python version
3.8
Steps to Reproduce
or
Expected Behavior
The 'Is full depth' field is UN-CHECKED when the page re-loads to add another Device Type.
The False state of a Boolean field is maintained when cloning.
Observed Behavior
The state of Boolean fields that are set to
False
are not carried over when creating an object and then using the 'Create and Add Another' option.For example, the DeviceType model defines:
So the Is full depth field value should be carried over when cloning an existing object or when the form re-loads after clicking 'Create and Add Another'. In both cases, the 'is_full_depth' field is omitted from the query string. For example, my test resulted in:
dcim/device-types/add/?manufacturer=1&u_height=1&subdevice_role=parent
The issue is partly in
utilities.utils.prepare_cloned_fields()
. This function has code that sets any field with a value of False to the empty string (''). The function then only adds fields that aren't set to a value of None or the empty string to the query params.I've tested commenting out lines 228 and 229. This adds the False boolean field back in to the query params, but still leaves the check-box on the form selected. I'm not sure of a solution to this, whilst still retaining the check-box widget, but I've overcome it by using something like this for the form field:
The text was updated successfully, but these errors were encountered: