mark required fields in ajaxable forms
authorJan Szejko <janek37@gmail.com>
Wed, 23 May 2018 15:18:55 +0000 (17:18 +0200)
committerJan Szejko <janek37@gmail.com>
Wed, 23 May 2018 15:18:55 +0000 (17:18 +0200)
src/ajaxable/templatetags/ajaxable_tags.py
src/ajaxable/utils.py

index ec90e47..9af58e9 100644 (file)
@@ -32,7 +32,7 @@ def pretty_field(field, template=None):
     return mark_safe(template % {
         'errors': field.errors,
         'input': field,
     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),
     })
 
         'helptext': force_unicode(field.help_text),
     })
 
index 9fd0091..80d398f 100755 (executable)
@@ -48,7 +48,7 @@ def require_login(request):
 
 def placeholdized(form):
     for field in form.fields.values():
 
 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
 
 
     return form