简体   繁体   中英

Sonata User Bundle: Managing many categories of users

I'm working on a Symfony 2.8 based project, I installed Sonata Admin Bundle and User Bundle and all is working perfectly.

I have a customized register and profile pages, and the users are well managed by the admin dashboard and all is at top. But, a new feature just appeared. So the users were meant to be University Professors, so I added all the fields necessary for representing them. But now they want also students to be able to register in the application, and be managed by admin dashboard as well. Do you have any ideas what will be the best way to separate the students from the professors, they will both have a lot of fields in common. In fact, I just need a flag (student or not). But how will they appear in distinct lists in the admin dashboard ? I'm thinking about groups but I'm not sure how to affect a user to a group when registering.

Thank you

If all you need is a flag, you can add it (lets just say you call it isProfessor), then add a datagrid filter on that flag.

This will allow you to filter on whether isProfessor is true or not.

https://sonata-project.org/bundles/admin/master/doc/reference/action_list.html#filters

If you want specific lists of professors/students you could create a custom list view for each:

https://sonata-project.org/bundles/admin/master/doc/cookbook/recipe_custom_action.html

Should be pretty straightforward.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM