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 ?

1 Answer 1

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' } }
Sign up to request clarification or add additional context in comments.

2 Comments

You can also use the read_only: true instead of disabled, but I don't know what differences there is between both.
Yes, I had to add the type parameters. Thanks. Should the doc be updated ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.