symfony 1.4 管理生成器未设置字段
我使用了“doctrine:generate-admin”任务。一切正常,但我想使用生成器.yml 文件取消设置某些表单字段,而不必在 Form 类本身中取消设置它们。像“updated_at”这样的东西我只需要在对象更新时保存,但我不希望它们显示在任何表单上,因此我不会收到任何表单验证错误。
这可能吗?我在生成器的参考页面上找不到任何可以让我执行此操作的内容,字段配置似乎只允许更改标签/凭据等。
I've used the "doctrine:generate-admin" task. Everything is working but I want to use the generator.yml file to unset some form fields there rather than having to unset them in the Form class itself. Things like "updated_at" I only ever need saved when the object is updated but I don't want them displayed on any forms, and therefore I won't get any form validation errors.
Is this possible? I can't find anything on the reference page for the generator that would let me do this, the fields configuration only seems to allow for changing the label/credentials etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您只需选择要显示的字段:
很奇怪您在参考页面上没有找到它。在这里:http://www.symfony-project.org /reference/1_4/en/06-Admin-Generator(导航至表单 -> 显示)。
编辑:
管理生成器使用 sfModelGeneratorConfiguration::getFormFields() 方法来检索要呈现的字段列表。如果您不指定“显示”选项,它只会采用所有字段。
是渲染所有字段还是仅渲染其中部分字段?如果晚了,您的表单中可能会出现重载的内容(例如 configure() 方法)。
You need to simply choose fields you want to display:
It's weird you didn't find it on the reference page. Here you go: http://www.symfony-project.org/reference/1_4/en/06-Admin-Generator (navigate to form -> display).
Edit:
Admin generator uses sfModelGeneratorConfiguration::getFormFields() method to retrieve list of fields to render. It only takes all fields if you won't specify the 'display' option.
Is it all the fields are rendered or just some of them? If it's the later than you might have something overloaded in your form (for example configure() method).
试试这个:
http://www.symfony-project。 org/reference/1_4/en/06-Admin-Generator#chapter_06_sub_hide
try this:
http://www.symfony-project.org/reference/1_4/en/06-Admin-Generator#chapter_06_sub_hide
除了如上所述隐藏管理模块的 config/generator.yml 中的字段之外,您还应该在相关表单中取消设置它们。因此,如果您想隐藏 Timestampable 模型的created_at和updated_at字段,请将lib/form/doctrine/ModelForm.class.php中的configure()方法更改为
Apart from hiding the fields in config/generator.yml of the admin module, as stated above, you should unset them in the related form. So if you want to hide the created_at and updated_at fields of a Timestampable model, alter the configure() method in lib/form/doctrine/ModelForm.class.php to