Symfony:自定义 sfDoctrineGuardPlugin 模块
我正在尝试自定义 sfGuardUser 模块的形式。安装 sfGuardDoctrinePlugin 后,我遵循 Symfony 的级联配置约定并创建了以下结构:
apps/backend/modules/sfGuardUser
apps/backend/modules/sfGuardUser/config
apps/backend/modules/sfGuardUser/config/generator.yml
在 generator.yml
文件中,我尝试按照建议覆盖默认插件设置在 此相关问题和此官方博客中的帖子:
generator: class: sfDoctrineGenerator param: config: fields: first_name: label: Name last_name: label: Surname email_address: label: Email updated_at: label: Last update date_format: f list: title: People display: [=username, name, email_address, last_login] sort: [username, asc] filter: display: [username, first_name, last_name, email_address] edit: title: Edit "%%name%%" new: title: Add a new user form: display: "User": [first_name, last_name, email_address, username, password, password_again] "Permissions and groups": [is_active, is_super_admin, groups_list]
但是表单仍然反映默认设置。例如,它仍然显示 permissions_list
。
此外,如果您尝试通过覆盖 sfGuardUserAdminForm 来取消设置小部件,您会发现它也不起作用。
我怎样才能避免这种情况并强制真正覆盖?我错过了什么吗?
谢谢!
更新1 我找到了一种解决方法,即为该组分配一个错误值,然后使用我想要的字段设置一个新组:
"User": [first_name, last_name, email_address, username, password, password_again]
"Permissions and groups": false
"Status and groups": [is_active, is_super_admin, groups_list]
更新 2 这是一个已记录的错误,但核心开发人员似乎没有处理它。该票证包含针对像我一样遇到此问题的人的补丁。
I'm trying to customize the forms of sfGuardUser module. After installing the sfGuardDoctrinePlugin, I followed the cascading-configuration convention of Symfony and created the following structure:
apps/backend/modules/sfGuardUser
apps/backend/modules/sfGuardUser/config
apps/backend/modules/sfGuardUser/config/generator.yml
Within the generator.yml
file, I tried to override default plugin settings as suggested in
this related question and this post in the official blog:
generator: class: sfDoctrineGenerator param: config: fields: first_name: label: Name last_name: label: Surname email_address: label: Email updated_at: label: Last update date_format: f list: title: People display: [=username, name, email_address, last_login] sort: [username, asc] filter: display: [username, first_name, last_name, email_address] edit: title: Edit "%%name%%" new: title: Add a new user form: display: "User": [first_name, last_name, email_address, username, password, password_again] "Permissions and groups": [is_active, is_super_admin, groups_list]
However the form still reflects the default settings. For instance, it's still displaying the permissions_list
.
Moreover, if you try to unset the widgets by overriding the sfGuardUserAdminForm you realize that it does not work either.
How can I avoid that and force a real overriding? Am I missing something?
Thanks!
UPDATE 1
I have found a workaround, which is assigning a false value to the group, and then set a new group with the fields I wanted:
"User": [first_name, last_name, email_address, username, password, password_again]
"Permissions and groups": false
"Status and groups": [is_active, is_super_admin, groups_list]
UPDATE 2
This is a documented bug, but it seems core developers are not dealing with it. The ticket included a patch for those who are experiencing this problem like me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,覆盖约定并不像您期望的插件的generator.yml 那样工作。最简单的方法是配置插件的generator.yml 文件,这就是我所做的。
您还可以将插件的generator.yml 移动(而不是复制)到您的应用程序/模块。此线程还有一个有趣的解决方案: http://oldforum.symfony- project.org/index.php/m/43279/
Unfortunately, overriding convention doesn't work the way you would expect with plugins' generator.yml. The easiest way is to configure the plugin's generator.yml file, which is what I do.
You can also move (not copy) the plugin's generator.yml to your app/module. There's also one interesting solution at this thread here: http://oldforum.symfony-project.org/index.php/m/43279/