隐藏表单 sfDoctrineGuard 中的字段
我正在尝试从 sfDoctrineGuard 生成的表单中删除一些字段。 我不关心用户的姓名或电子邮件,我只希望他们有一个用户名和密码。
我尝试编辑 /lib/form/doctrine/sfDoctrineGuardPlugin/sfGuardUserForm.class.php :
class sfGuardUserForm extends PluginsfGuardUserForm
{
public function configure()
{
unset(
$this['first_name'],
$this['last_name'],
$this['email_adress']
);
}
}
但这没有任何作用。我编辑的文件正确吗?
编辑 让这些字段消失的唯一方法是编辑 /plugins/ 目录中的文件!
plugins/sfDoctrineGuardPlugin/lib/form/doctrine/sfGuardUserAdminForm.class.php
I'm trying to remove some fields from the form generated by sfDoctrineGuard.
I don't care about the name or email of my users, I just want them to have an username and a password.
I've tried editing /lib/form/doctrine/sfDoctrineGuardPlugin/sfGuardUserForm.class.php :
class sfGuardUserForm extends PluginsfGuardUserForm
{
public function configure()
{
unset(
$this['first_name'],
$this['last_name'],
$this['email_adress']
);
}
}
But that did nothing. Am I editing the right file ?
EDIT The only way I can make those fields disappear is by editing the file in the /plugins/ directory !
plugins/sfDoctrineGuardPlugin/lib/form/doctrine/sfGuardUserAdminForm.class.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它可能使用 sfGuardUserAdminForm 而不是 sfGuardUserForm - 检查调试栏的视图选项卡,它应该告诉您。
此类位于插件中,因此您应该在项目的 lib/form 文件夹下将其子类化,并将现有的配置方法复制到子类中。
然后,您可以通过编辑 gnerator.yml 来告诉它使用此表单 - 再次将其从插件复制到您的项目/应用程序的模块文件夹(如果您还没有这样做)。您需要更改生成器/参数/配置/表单/类。您还需要从表单/显示键中删除这些字段(如果存在),否则它会抱怨它们不存在。
Its probably using sfGuardUserAdminForm rather than sfGuardUserForm - check the view tab of the debug bar and it should tell you.
This class lives in the plugin, so you should subclass it under your project's lib/form folder and copy your existing configure method to the subclass.
You can then tell it to use this form by editing gnerator.yml - again, copy it to your project/application's modules folder from the plugin if you haven't already. You need to change generator/param/config/form/class. You also need to remove the fields from the form/display key if they are there, or it'll complain they don't exist.
这些字段在
generator.yml
文件中配置。但删除那里不会像你预期的那样工作。您需要从
schema.yml
、表单类和模型类中手动删除这些字段。These fields are configured in
generator.yml
file.But removing there will not work as you expected. You need to manually remove these fields from
schema.yml
, form- and model classes.