From 0f25b87de7e9c7a8efb3df4633825d0b93aefdf9 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Tue, 1 Oct 2024 15:52:52 +0200 Subject: [PATCH] Make it possible to use SubmitField for LabelSubmit --- python/nav/web/crispyforms.py | 8 +++++++- .../templates/custom_crispy_templates/submit_field.html | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/python/nav/web/crispyforms.py b/python/nav/web/crispyforms.py index 6ad0b77bba..03365591ce 100644 --- a/python/nav/web/crispyforms.py +++ b/python/nav/web/crispyforms.py @@ -140,17 +140,23 @@ class SubmitField: :param name: The name attribute of the submit field. :param value: The display text of the submit button. :param css_classes: Additional CSS classes to apply to the submit button. + :param has_empty_label: If an empty label is added above the submit button to align it within a row. :ivar input_type: The type of input, which is 'submit' for this class. :type input_type: str """ def __init__( - self, name: str = 'submit', value: str = 'Submit', css_classes: str = '' + self, + name: str = 'submit', + value: str = 'Submit', + css_classes: str = '', + has_empty_label: bool = False, ): """Constructor method""" self.name = name self.value = value self.css_classes = css_classes + self.has_empty_label = has_empty_label self.input_type = 'submit' diff --git a/python/nav/web/templates/custom_crispy_templates/submit_field.html b/python/nav/web/templates/custom_crispy_templates/submit_field.html index d7803c9c44..58c11bd831 100644 --- a/python/nav/web/templates/custom_crispy_templates/submit_field.html +++ b/python/nav/web/templates/custom_crispy_templates/submit_field.html @@ -1,5 +1,7 @@ -{# NB! This field can be used as a replacement of crispy's Submit #} - +{# NB! This field can be used as a replacement of crispy's Submit and our custom LabelSubmit #} +{% if input.has_empty_label %} + +{% endif %}