From 2bd1e420fa4fe32cd762410dd0a6f243423b03e6 Mon Sep 17 00:00:00 2001 From: ariannedee Date: Tue, 4 Aug 2020 22:18:58 -0700 Subject: [PATCH] Highlight inputs if they are empty but required --- edivorce/apps/core/templatetags/input_field.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/edivorce/apps/core/templatetags/input_field.py b/edivorce/apps/core/templatetags/input_field.py index df4703d5..149705e7 100644 --- a/edivorce/apps/core/templatetags/input_field.py +++ b/edivorce/apps/core/templatetags/input_field.py @@ -63,6 +63,13 @@ def input_field(context, type, name='', value='', multiple='', **kwargs): """ Usage: when specifying data attributes in templates, use "data_" instead of "data-". """ + error = context.get(f'{name}_error', False) + if error: + if 'class' in kwargs: + kwargs['class'] += ' error' + else: + kwargs['class'] = 'error' + if type == "textarea": attributes = additional_attributes(**kwargs) if value == '':