mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 04:58:16 -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):
|
def compress(cls, data):
|
||||||
if data:
|
if data:
|
||||||
size, unit = 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]
|
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 }}
|
{{ field }}
|
||||||
{% if bulk_nullable %}
|
{% if bulk_nullable %}
|
||||||
<div class="form-check my-1">
|
<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>
|
<label class="form-check-label">Set Null</label>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user