I'm developing an app in symfony for follow the workflow of a document. In the lifecycle of the document, take part various departments, I mean, people of each department with his own role inside de app (ROLE_USER
, ROLE_SYSTEMS
...). I have the same form for all of them but in the different states of the lifecycle of the document one of them has to complete specific fields and the rest will be disable or readonly.
I want to know how is the best way to do this in Symfony, check the role and disable the fileds the user can't edit in every moment of the lifecycle.
I have investigated and find something like this for my twig templates, but I will have to do this for each field and each role and I don't know if I can apply this to field attributes like disabled or readonly, is it?.
{{% if is_granted('ROLE_ADMIN') %}
<a href="...">Delete</a>
{% endif %}
I also heard about voters but I don't have very clear how it works and if it is appropriate for my situation.
What do you think?