我正在努力制定标准" created_at"在编辑表单中只读取字段。在the doc之后,您必须添加以下配置:
MyEntity:
form:
fields:
- { property: 'created_at', type_options: { widget: 'single_text' } }
但它会引发以下错误:
An Exception was thrown while handling: The option "widget" does not exist. Defined options are: "action", "allow_extra_fields"...
是否有明显的添加/修改内容?
答案 0 :(得分:7)
如果您想将字段设为只读,则应该使用"禁用"选项:
MyEntity:
form:
fields:
- { property: 'created_at', type_options: { disabled: true } }
如果这对您不起作用,您可以尝试明确设置表单类型吗?
MyEntity:
form:
fields:
- { property: 'created_at', type: 'datetime', type_options: { widget: 'single_text' } }