diff --git a/helpdesk/forms.py b/helpdesk/forms.py index af754ca5..8339df13 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -424,7 +424,7 @@ class AbstractTicketForm(CustomFieldMixin, forms.Form): class TicketForm(AbstractTicketForm): """ - Ticket Form creation for registered users. + Ticket Form for registered users. """ submitter_email = forms.EmailField( @@ -451,15 +451,20 @@ class TicketForm(AbstractTicketForm): choices=(), ) - def __init__(self, *args, **kwargs): + def __init__( + self, instance=None, queue_choices=None, body_reqd=True, *args, **kwargs + ): """ Add any custom fields that are defined to the form. + The view will have injected extra kwargs into the form init + by calling the views get_form_kwargs() which must be removed before + calling super() because the django.forms.forms.BaseForm only + supports specific kwargs and so will crash and burn if they are left in """ - queue_choices = kwargs.pop("queue_choices") - super().__init__(*args, **kwargs) - - self.fields["queue"].choices = queue_choices + if queue_choices: + self.fields["queue"].choices = queue_choices + self.fields["body"].required = body_reqd if helpdesk_settings.HELPDESK_STAFF_ONLY_TICKET_OWNERS: assignable_users = User.objects.filter( is_active=True, is_staff=True diff --git a/helpdesk/templates/helpdesk/ticket.html b/helpdesk/templates/helpdesk/ticket.html index 26a0dadb..99167e67 100644 --- a/helpdesk/templates/helpdesk/ticket.html +++ b/helpdesk/templates/helpdesk/ticket.html @@ -18,6 +18,9 @@ {% endblock %} {% block helpdesk_body %} + {% if form.errors %} + {% include 'helpdesk/include/alert_form_errors.html' %} + {% endif %} {% if helpdesk_settings.HELPDESK_TRANSLATE_TICKET_COMMENTS %}
@@ -95,7 +98,7 @@