Symfony formbuilder if field is empty make it read only in edit easyadmin

In my easy admin I have 2 fields name and label, name is read only and label should be read only when it’s not empty in the edit form. I am not sure how to do that.

This is how I build my form:

I have a Name field that is read only

$builder->add(
        'name',
        TextType::class,
        [
            'disabled' => true,
        ]
    );
$builder->add(
    'label',
    TextType::class,
    [
        'required' => true,
        'attr'     => [
            'attribute_class' => Label::class,
        ],
    ]
);

Can I do this here or is there an other approach?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *