From: Jan Szejko Date: Wed, 23 May 2018 15:18:55 +0000 (+0200) Subject: mark required fields in ajaxable forms X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/6ff3fa3548cb227f9c26bd5e7552f1769c9ce277?ds=sidebyside mark required fields in ajaxable forms --- diff --git a/src/ajaxable/templatetags/ajaxable_tags.py b/src/ajaxable/templatetags/ajaxable_tags.py index ec90e4794..9af58e935 100644 --- a/src/ajaxable/templatetags/ajaxable_tags.py +++ b/src/ajaxable/templatetags/ajaxable_tags.py @@ -32,7 +32,7 @@ def pretty_field(field, template=None): return mark_safe(template % { 'errors': field.errors, 'input': field, - 'label': force_unicode(field.label), + 'label': ('*' if field.field.required else '') + force_unicode(field.label), 'helptext': force_unicode(field.help_text), }) diff --git a/src/ajaxable/utils.py b/src/ajaxable/utils.py index 9fd009108..80d398f73 100755 --- a/src/ajaxable/utils.py +++ b/src/ajaxable/utils.py @@ -48,7 +48,7 @@ def require_login(request): def placeholdized(form): for field in form.fields.values(): - field.widget.attrs['placeholder'] = field.label + field.widget.attrs['placeholder'] = field.label + ('*' if field.required else '') return form