mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 21:18:16 -06:00
Move annotation of field validation failures to CSS
This commit is contained in:
parent
755da9fd73
commit
43a11ddce8
BIN
netbox/project-static/dist/netbox.css
vendored
BIN
netbox/project-static/dist/netbox.css
vendored
Binary file not shown.
@ -37,16 +37,6 @@ $spacing-s: $input-padding-x;
|
||||
.ss-main {
|
||||
color: $form-select-color;
|
||||
|
||||
&.is-invalid .ss-single-selected,
|
||||
&.is-invalid .ss-multi-selected {
|
||||
border-color: $form-feedback-icon-invalid-color;
|
||||
}
|
||||
|
||||
&.is-valid .ss-single-selected,
|
||||
&.is-valid .ss-multi-selected {
|
||||
border-color: $form-feedback-icon-valid-color;
|
||||
}
|
||||
|
||||
.ss-single-selected,
|
||||
.ss-multi-selected {
|
||||
padding: $form-select-padding-y $input-padding-x $form-select-padding-y $form-select-padding-x;
|
||||
@ -195,3 +185,11 @@ $spacing-s: $input-padding-x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply red border for fields inside a row with .has-errors
|
||||
.has-errors {
|
||||
.ss-single-selected,
|
||||
.ss-multi-selected {
|
||||
border-color: $red;
|
||||
}
|
||||
}
|
||||
|
@ -16,3 +16,12 @@ form.object-edit {
|
||||
content: '\f06C4';
|
||||
}
|
||||
}
|
||||
|
||||
// Set red border on form fields inside a row with .has-errors
|
||||
.has-errors {
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
border: 1px solid $red;
|
||||
}
|
||||
}
|
||||
|
@ -51,19 +51,6 @@ class BootstrapMixin:
|
||||
# if 'placeholder' not in field.widget.attrs and field.label is not None:
|
||||
# field.widget.attrs['placeholder'] = field.label
|
||||
|
||||
def is_valid(self):
|
||||
is_valid = super().is_valid()
|
||||
|
||||
# Apply is-invalid CSS class to fields with errors
|
||||
if not is_valid:
|
||||
for field_name in self.errors:
|
||||
# Ignore e.g. __all__
|
||||
if field := self.fields.get(field_name):
|
||||
css = field.widget.attrs.get('class', '')
|
||||
field.widget.attrs['class'] = f'{css} is-invalid'
|
||||
|
||||
return is_valid
|
||||
|
||||
|
||||
class CheckLastUpdatedMixin(forms.Form):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user