Usually we can customize the attribute class of an input field from twig with
{{ form_widget(form.username,{'attr':{
'class':'input',
'placeholder':'Write your username'
}}) }}
But how to add a class depending upon the fact that this field has an error?
For example I want my input tag to have an additional class "is-danger" if there is an error encountered during submission