Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 873
COil Avatar asked Dec 11 '22 18:12

COil


1 Answers

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' } }
like image 73
Javier Eguiluz Avatar answered Dec 14 '22 22:12

Javier Eguiluz