Ani*_*ida 1 symfony symfony2-easyadmin
我必须将用户的角色显示为列表:我想单击选项而不是键入它。我会得到像 ROLE_USER、ROLE_ADMIN、...
是否有任何配置更改比我必须在 config.yml 中进行?
谢谢你的帮助,阿尼斯
是的。您必须使用选择类型及其expanded
选项(以及可选的multiple
选项)。请记住,用于表单类型的type_options
选项在选项中定义:
easy_admin:
# ...
entities:
User:
# ...
form:
fields:
- { property: 'roles', type: 'choice', type_options: { expanded: true } }
Run Code Online (Sandbox Code Playgroud)
如果需要,您还可以在 YAML 文件中定义选项:
easy_admin:
# ...
entities:
User:
# ...
form:
fields:
- property: 'roles'
type: 'choice'
type_options:
expanded: true
choices: { 'ROLE_USER': 'Normal user', 'ROLE_ADMIN': 'Administrator' }
Run Code Online (Sandbox Code Playgroud)