Hi:
I would like to add/remove some html when an error validation occurs in an ActiveForm
The standard template for me is typical “{label}{input}{hint}{error}” … and that generates a simple input snippet:
<div class="form-group">
<input type="text" class="form-control">
</div>
<span class="text-hint">Hint</span>
But I would like when an input shows an error to add some code
<div class="form-group">
<input type="text" class="form-control border-danger">
<div class="form-control-feedback text-danger">
<i class="icon-cancel-circle2"></i>
</div>
</div>
<span class="text-hint hidden">Hint</span>
<span class="form-text text-danger">Invalid state helper</span>
So, I’d like:
- to add a class for input
- to add a div with an icon
- to add a class to hint (to hide it)
I have my own ActiveForm and ActiveField classes to override other things, but I don’t know how to tell the form to add this.
I was thinking about using the “afterValidate” (as shown here https://www.yiiframework.com/doc/guide/2.0/en/input-form-javascript) but I don’t know how to add in my ActiveForm class to have it in all my forms.
Thank you