-
-
Notifications
You must be signed in to change notification settings - Fork 141
Open
Description
bootstrap allows the use of is-valid
and is-invalid
for fields of validated forms (bounded). Whereas is-invalid
class can be easily added as
{% render_field form.field1|add_error_class:'is-invalid' %}
It is not easy to do so with is-valid
because blindly adding the class will mark fields as valid for unbounded forms.
Is it possible to add another filter called add_valid_class
as follows?
@register.filter("add_valid_class")
@silence_without_field
def add_valid_class(field, css_class):
if field.form.is_bound and not (hasattr(field, "errors") and field.errors):
return add_class(field, css_class)
return
I suppose it also makes sense to add WIDGET_VALID_CLASS
so that I can do
{% with WIDGET_ERROR_CLASS='is-invalid' WIDGET_VALID_CLASS="is-valid" %}
{% render_field form.field1 %}
{% render_field form.field2 %}
{% render_field form.field3 %}
{% endwith %}
Metadata
Metadata
Assignees
Labels
No labels