I have an entity that contains a method to determine if I need to disable a field or not.
In my view, I tried this:
<div>{{
form_widget(form.myValue, {
'attr': {
'disabled': form.get('value').isMyValueDisabled(),
'(...)': '(...)', {# several other attributes #}
}
})
}}</div>
But disabled attribute on an html field disables my field even if it contains false.
This is a shared form, so I can’t create a logic in the ->buildForm() method of my Type.
Do you have any suggestion to disable my field on the Twig view?
Okey I found a solution :
If you know a way without JavaScript, I would love to learn it!