4

我正在尝试在编辑表单中将标准的“created_at”字段设为只读。按照文档,您必须添加以下配置:

    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"...

有什么明显的添加/修改吗?

4

1 回答 1

13

如果您想将该字段设为只读,您可能应该使用“禁用”选项:

MyEntity:
    form:
        fields:
            - { property: 'created_at', type_options: { disabled: true } }

如果这对您不起作用,您可以尝试显式设置表单类型吗?

MyEntity:
    form:
        fields:
            - { property: 'created_at', type: 'datetime', type_options: { widget: 'single_text' } }
于 2016-03-07T12:23:22.473 回答