Search code examples
phpformssymfonysymfony2-easyadmin

EasyAdminBundle entity form fields customization


I am trying to make a standard "created_at" field readonly in the edit form. Following the doc you have to add the following configuration:

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

But it throws the following error:

An Exception was thrown while handling: The option "widget" does not exist. Defined options are: "action", "allow_extra_fields"...

Is there something obvious to add/modify ?


Solution

  • If you want to make the field read-only, you should probably use "disabled" option:

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

    If this doesn't work for you, can you try to set the form type explicitly?

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