Ensure deterministic ordering of attriubte fields

This commit is contained in:
Jeremy Stretch 2025-03-26 17:11:37 -04:00
parent c1ff89e98f
commit 0d2a8b8b85

View File

@ -489,11 +489,12 @@ class ModuleTypeForm(NetBoxModelForm):
prop = JSONSchemaProperty(**options)
attr_fields[name] = prop.to_form_field(name, required=name in required_fields)
return attr_fields
return dict(sorted(attr_fields.items()))
def _post_clean(self):
# Compile attribute data from the individual form fields
if self.cleaned_data.get('profile'):
self.instance.attribute_data = {
name[5:]: self.cleaned_data[name] # Remove the attr_ prefix
for name in self.attr_fields if self.cleaned_data[name] is not None