Form UX: Add more helpful placeholders

This commit is contained in:
Raphael Michel
2017-10-06 11:05:24 +02:00
parent 29b1a3dca3
commit 3eeb70ae36
4 changed files with 74 additions and 7 deletions

View File

@@ -107,6 +107,9 @@ class EventWizardBasicsForm(I18nModelForm):
self.initial['timezone'] = get_current_timezone_name()
self.fields['locale'].choices = [(a, b) for a, b in settings.LANGUAGES if a in self.locales]
self.fields['location'].widget.attrs['rows'] = '3'
self.fields['location'].widget.attrs['placeholder'] = _(
'Sample Conference Center\nHeidelberg, Germany'
)
self.fields['slug'].widget.prefix = build_absolute_uri(self.organizer, 'presale:organizer.index')
if self.has_subevents:
del self.fields['presale_start']
@@ -196,6 +199,9 @@ class EventUpdateForm(I18nModelForm):
super().__init__(*args, **kwargs)
self.fields['slug'].widget.attrs['readonly'] = 'readonly'
self.fields['location'].widget.attrs['rows'] = '3'
self.fields['location'].widget.attrs['placeholder'] = _(
'Sample Conference Center\nHeidelberg, Germany'
)
class Meta:
model = Event
@@ -352,13 +358,13 @@ class EventSettingsForm(SettingsForm):
label=_("Imprint URL"),
required=False,
)
confirm_text = forms.CharField(
confirm_text = I18nFormField(
label=_('Confirmation text'),
help_text=_('This text needs to be confirmed by the user before a purchase is possible. You could for example '
'link your terms of service here. If you use the Pages feature to publish your terms of service, '
'you don\'t need this setting since you can configure it there.'),
required=False,
widget=forms.Textarea(attrs={"rows": 3})
widget=I18nTextarea
)
contact_mail = forms.EmailField(
label=_("Contact address"),
@@ -387,6 +393,14 @@ class EventSettingsForm(SettingsForm):
})
return data
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['confirm_text'].widget.attrs['rows'] = '3'
self.fields['confirm_text'].widget.attrs['placeholder'] = _(
'e.g. I hereby confirm that I have read and agree with the event organizer\'s terms of service '
'and agree with them.'
)
class PaymentSettingsForm(SettingsForm):
payment_term_days = forms.IntegerField(
@@ -538,25 +552,51 @@ class InvoiceSettingsForm(SettingsForm):
choices=[]
)
invoice_address_from = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5}), required=False,
widget=forms.Textarea(attrs={
'rows': 5,
'placeholder': _(
'Sample Event Company\n'
'Albert Einstein Road 52\n'
'12345 Samplecity'
)
}),
required=False,
label=_("Your address"),
help_text=_("Will be printed as the sender on invoices. Be sure to include relevant details required in "
"your jurisdiction (e.g. your VAT ID).")
"your jurisdiction.")
)
invoice_introductory_text = I18nFormField(
widget=I18nTextarea,
widget_kwargs={'attrs': {
'rows': 3,
'placeholder': _(
'e.g. With this document, we sent you the invoice for your ticket order.'
)
}},
required=False,
label=_("Introductory text"),
help_text=_("Will be printed on every invoice above the invoice rows.")
)
invoice_additional_text = I18nFormField(
widget=I18nTextarea,
widget_kwargs={'attrs': {
'rows': 3,
'placeholder': _(
'e.g. Thank you for your purchase! You can find more information on the event at ...'
)
}},
required=False,
label=_("Additional text"),
help_text=_("Will be printed on every invoice below the invoice total.")
)
invoice_footer_text = I18nFormField(
widget=I18nTextarea,
widget_kwargs={'attrs': {
'rows': 5,
'placeholder': _(
'e.g. your bank details, legal details like your VAT ID, registration numbers, etc.'
)
}},
required=False,
label=_("Footer"),
help_text=_("Will be printed centered and in a smaller font at the end of every invoice page.")
@@ -599,7 +639,13 @@ class MailSettingsForm(SettingsForm):
required=False,
widget=I18nTextarea,
help_text=_("This will be attached to every email. Available placeholders: {event}"),
validators=[PlaceholderValidator(['{event}'])]
validators=[PlaceholderValidator(['{event}'])],
widget_kwargs={'attrs': {
'rows': '4',
'placeholder': _(
'e.g. your contact details'
)
}}
)
mail_text_order_placed = I18nFormField(
@@ -704,14 +750,17 @@ class MailSettingsForm(SettingsForm):
)
smtp_host = forms.CharField(
label=_("Hostname"),
required=False
required=False,
widget=forms.TextInput(attrs={'placeholder': 'mail.example.org'})
)
smtp_port = forms.IntegerField(
label=_("Port"),
required=False
required=False,
widget=forms.TextInput(attrs={'placeholder': 'e.g. 587, 465, 25, ...'})
)
smtp_username = forms.CharField(
label=_("Username"),
widget=forms.TextInput(attrs={'placeholder': 'myuser@example.org'}),
required=False
)
smtp_password = forms.CharField(