Modify label_attr field in Symfony 5 form builder

When building a form in symfony form builder changing the choice attribute can be done.
However, for the label attribute this doesn’t seem possible.

Here is how i modify the choice:

$builder->add('type', EntityType::class, [
    'class' => Resourcetype::class,
    'multiple' => true,
    'expanded' => true,
    'choice_attr' => function (?Resourcetype $type) {
        return ['class' => $type->getSafeName() . '-parent parent' : $type->getSafeName()

Is this possible for the label_attr field?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

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