File tree Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 11{% for error in field.errors %}
2- < span id ="error_{{ field.auto_id }}_{{ forloop.counter }} " class ="error-msg "> {{ error }}</ span >
2+ < div id ="error_{{ field.auto_id }}_{{ forloop.counter }} " class ="invalid-feedback "> {{ error }}</ div >
33{% endfor %}
Original file line number Diff line number Diff line change 11{% for error in field.errors %}
2- < p id ="error_{{ field.auto_id }}_{{ forloop.counter }} " class ="help-block "> {{ error }}</ p >
2+ < div id ="error_{{ field.auto_id }}_{{ forloop.counter }} " class ="invalid-feedback "> {{ error }}</ div >
33{% endfor %}
Original file line number Diff line number Diff line change 11{% if field.help_text %}
2- < p class ="help-block "> {{ field.help_text|safe }}</ p >
2+ < small class ="form-text text-muted "> {{ field.help_text|safe }}</ small >
33{% endif %}
Original file line number Diff line number Diff line change 1414
1515
1616def _preprocess_fields (form ):
17+ invalid_form = True if len (form .errors ) > 0 else False
18+
1719 for field in form .fields :
1820 name = form .fields [field ].widget .__class__ .__name__ .lower ()
1921 if not name .startswith ("radio" ) and not name .startswith ("checkbox" ):
22+
23+ if invalid_form :
24+ if field in form .errors :
25+ validation_state = ' is-invalid'
26+ else :
27+ validation_state = ' is-valid'
28+ else :
29+ validation_state = ''
30+
2031 try :
21- form .fields [field ].widget .attrs ["class" ] += " form-control"
32+ form .fields [field ].widget .attrs ["class" ] += ' form-control' + validation_state
2233 except KeyError :
23- form .fields [field ].widget .attrs ["class" ] = " form-control"
34+ form .fields [field ].widget .attrs ["class" ] = ' form-control' + validation_state
2435 return form
2536
2637
You can’t perform that action at this time.
0 commit comments