EasyAdminBundle 实体表单字段自定义


EasyAdminBundle entity form fields customization

我正在尝试在编辑表单中使标准的"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"...

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

如果要

使该字段为只读,则可能应该使用"禁用"选项:

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

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

MyEntity:
    form:
        fields:
            - { property: 'created_at', type: 'datetime', type_options: { widget: 'single_text' } }