mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-16 20:48:17 -06:00
add form validation on memory widget
This commit is contained in:
parent
5aee17e998
commit
5cb5033b1e
@ -177,8 +177,12 @@ class MemoryField(forms.MultiValueField):
|
||||
def compress(cls, data):
|
||||
if data:
|
||||
size, unit = data
|
||||
if size:
|
||||
if size and not unit:
|
||||
raise forms.ValidationError("Memory unit cannot be blank.")
|
||||
elif size and unit:
|
||||
return size * cls.MULTIPLIERS[unit]
|
||||
elif not size and unit:
|
||||
raise forms.ValidationError("Please enter a memory value when unit is selected.")
|
||||
|
||||
|
||||
#
|
||||
|
@ -112,7 +112,7 @@
|
||||
{{ field }}
|
||||
{% if bulk_nullable %}
|
||||
<div class="form-check my-1">
|
||||
<input type="checkbox" class="form-check-input" name="_nullify" value="{{ field.name }}_0" />
|
||||
<input type="checkbox" class="form-check-input" name="_nullify" value="{{ field.name }}" />
|
||||
<label class="form-check-label">Set Null</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user