From f8ed21c8197a317d5bdaae41aca4db8d8a101389 Mon Sep 17 00:00:00 2001 From: Johan von Forstner Date: Wed, 19 Jul 2017 11:02:07 +0200 Subject: [PATCH] Fix #130 -- Mark required question fields at checkout (#564) * Fix #130: Mark required question fields at checkout * Add legend --- src/pretix/presale/forms/checkout.py | 4 ++++ .../pretixpresale/event/checkout_questions.html | 5 +++++ src/pretix/static/pretixpresale/scss/_forms.scss | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/src/pretix/presale/forms/checkout.py b/src/pretix/presale/forms/checkout.py index 9a429afa72..d355f3bfff 100644 --- a/src/pretix/presale/forms/checkout.py +++ b/src/pretix/presale/forms/checkout.py @@ -19,6 +19,7 @@ from pretix.presale.signals import contact_form_fields, question_form_fields class ContactForm(forms.Form): + required_css_class = 'required' email = forms.EmailField(label=_('E-mail'), help_text=_('Make sure to enter a valid email address. We will send you an order ' 'confirmation including a link that you need in case you want to make ' @@ -48,6 +49,7 @@ class ContactForm(forms.Form): class InvoiceAddressForm(forms.ModelForm): + required_css_class = 'required' class Meta: model = InvoiceAddress @@ -61,6 +63,7 @@ class InvoiceAddressForm(forms.ModelForm): def __init__(self, *args, **kwargs): self.event = event = kwargs.pop('event') super().__init__(*args, **kwargs) + self.fields['name'].form_group_class = 'required' if not event.settings.invoice_address_vatid: del self.fields['vat_id'] if not event.settings.invoice_address_required: @@ -118,6 +121,7 @@ class QuestionsForm(forms.Form): the attendee name for admission tickets, if the corresponding setting is enabled, as well as additional questions defined by the organizer. """ + required_css_class = 'required' def __init__(self, *args, **kwargs): """ diff --git a/src/pretix/presale/templates/pretixpresale/event/checkout_questions.html b/src/pretix/presale/templates/pretixpresale/event/checkout_questions.html index 179158e309..895725ade5 100644 --- a/src/pretix/presale/templates/pretixpresale/event/checkout_questions.html +++ b/src/pretix/presale/templates/pretixpresale/event/checkout_questions.html @@ -5,6 +5,11 @@ {% block content %}

{% trans "Checkout" %}

{% trans "Before we continue, we need you to answer some questions." %}

+

+ {% blocktrans trimmed %} + You need to fill all fields that are marked with * to continue. + {% endblocktrans %} +

{% csrf_token %}
diff --git a/src/pretix/static/pretixpresale/scss/_forms.scss b/src/pretix/static/pretixpresale/scss/_forms.scss index 9418a800c1..7ea45bb44d 100644 --- a/src/pretix/static/pretixpresale/scss/_forms.scss +++ b/src/pretix/static/pretixpresale/scss/_forms.scss @@ -33,3 +33,12 @@ @include box-shadow($shadow); } } + +.required-legend span { + color: $brand-primary; + font-weight: bold; +} +.form-group.required .control-label:after { + content: '*'; + color: $brand-primary +}