1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 08:56:07 +00:00
webvirtcloud/webvirtcloud/bootstrap.py
catborise 558eec527c fix: a rejected form marks only its fields in error
django-bootstrap5 marks every error-free field of a sent form green
(is-valid), so a form that was refused and not saved looked approved
beside its red message. A field renderer of the panel's own marks only
the fields in error; the others look as they did before the form was
sent. Set in settings.py.template (BOOTSTRAP5['field_renderers']).
2026-11-18 07:53:46 +03:00

12 lines
483 B
Python

"""django-bootstrap5's field renderer, marking only the fields in error."""
from django_bootstrap5.renderers import FieldRenderer as BootstrapFieldRenderer
class FieldRenderer(BootstrapFieldRenderer):
"""A sent form marks its fields in error red and leaves the others as
they were: a green "valid" mark on a form that was not saved reads as if
it had been."""
def get_server_side_validation_classes(self):
return "is-invalid" if self.field_errors else ""