4

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 ?

COil
  • 7,201
  • 2
  • 50
  • 98

1 Answers1

13

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' } }
Javier Eguiluz
  • 3,987
  • 2
  • 23
  • 44
  • 2
    You can also use the `read_only: true` instead of `disabled`, but I don't know what differences there is between both. – Alex Rock Mar 07 '16 at 13:06
  • Yes, I had to add the type parameters. Thanks. Should the doc be updated ? – COil Mar 07 '16 at 15:12