I can change the class of my inputs, but not for my labels. How can I change class of my dynamics labels . I can't when I use 'label_attr', because it's a type Closure.
$builder
->add('skill', EntityType::class, [
'class' => Skill::class,
'query_builder' => function (SkillRepository $r) {
return $r->createQueryBuilder('i')
->orderBy('i.color', 'ASC');
},
'label' => 'Mes compétences',
// input OK !
'choice_attr' => function (?Skill $color) {
return $color ? ['class' => 'color_'.$color->getColor()] : [];
},
// ERROR
'label_attr' => function (?Skill $color) {
return $color ? ['class' => 'color_'.$color->getColor()] : [];
},
'attr' => [
'class' => 'btn'
],
'choice_label' => 'name',
'multiple' => true,
'expanded' => true,
])
An error has occurred resolving the options of the form "Symfony\Bridge\Doctrine\Form\Type\EntityType": The option "label_attr" with value Closure is expected to be of type "array", but is of type "Closure".
// ERROR
'label_attr' => function (?Skill $color) {
return $color ? ['class' => 'color_'.$color->getColor()] : [];
},
Aucun commentaire:
Enregistrer un commentaire