生成的 symfony 模块中用于编辑或创建对象的不同小部件
在下面的generator.yml中,我可以更改后端使用的表单的类。但是,我希望在编辑现有对象或创建新对象时有不同的形式。
编辑对象时,我想取消设置“onset”字段,而在创建新对象时不会丢失它。这可能吗?如果可能的话,如何实现?
JobeetCategory:
columns:
name: { type: string(255), notnull: true, unique: true }
test: { type: string(255) }
onset: { type: boolean }
generator.yml:
config:
actions: ~
fields: ~
list:
title: Category Management
filter: ~
form:
class: TestForm
edit:
title: Editing Category "%%name%%"
new:
title: New Category
In the following generator.yml, I can change the class for the form used in the backend. However, I would like to have different forms for when editing an existing object, or when creating a new one.
When editing an object, I want to unset the field 'onset', without losing it when creating a new object. Is this possible, and if so, how?
JobeetCategory:
columns:
name: { type: string(255), notnull: true, unique: true }
test: { type: string(255) }
onset: { type: boolean }
generator.yml:
config:
actions: ~
fields: ~
list:
title: Category Management
filter: ~
form:
class: TestForm
edit:
title: Editing Category "%%name%%"
new:
title: New Category
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以有条件地设置或取消设置表单类中的小部件,具体取决于您的对象是新对象还是正在编辑:
You can conditionally set or unset widgets inside your form class, depending on wether your object is new or being edited: