From 6ff3fa3548cb227f9c26bd5e7552f1769c9ce277 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Wed, 23 May 2018 17:18:55 +0200 Subject: [PATCH] mark required fields in ajaxable forms --- src/ajaxable/templatetags/ajaxable_tags.py | 2 +- src/ajaxable/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 -- 2.20.1