Search code examples
symfonyeasyadmineasyadmin3

Easy admin conditional fields


Stack is symf 5 and EA 3. I have a problem with showing different data for one AssociationField. I want to show different values of that field for different roles. Something that query builder do in Symfony forms. Any help?


Solution

  • You probably need to create a switch statement in the CRUD Controller which will render that field differently based on what is the current user role. Remember, that one user can have multiple roles by default, so You need to specify which role index should it take to statement as a parameter.

    But the true question is: Do You really need that functionality? If so, You probably should consider giving Your user class additionally a configuration array, where You will store the config of the preferred way for data presentation.

    You do not tell much about the background of Your problem, so I hope my answer address it correctly.