diff --git a/reference/forms/types/options/choice_attr.rst.inc b/reference/forms/types/options/choice_attr.rst.inc index ac149f3999d..b86b7450778 100644 --- a/reference/forms/types/options/choice_attr.rst.inc +++ b/reference/forms/types/options/choice_attr.rst.inc @@ -13,6 +13,20 @@ If an array, the keys of the ``choices`` array must be used as keys:: use Symfony\Component\Form\Extension\Core\Type\ChoiceType; // ... + $builder->add('fruits', ChoiceType::class, [ + 'choices' => [ + 'Apple' => 1, + 'Banana' => 2, + 'Durian' => 3, + ], + 'choice_attr' => [ + 'Apple' => ['data-color' => 'Red'], + 'Banana' => ['data-color' => 'Yellow'], + 'Durian' => ['data-color' => 'Green'], + ], + ]); + + // or use a callable $builder->add('attending', ChoiceType::class, [ 'choices' => [ 'Yes' => true,