在我的Symfony表单中,我有一个ChoiceType,我想将属性传递给标签,例如“ choice_attr”。
所以我尝试了一个“ choice_label_attr”选项,告诉自己它会存在,但不存在。
有人会有想法吗?
->add('discountType',ChoiceType::class,[
"label" => "Réduction","choices" => [
"Réduction en pourcentage" => "percent","Réduction d'un montant fixe" => "amount",],"choice_attr" => function($choice,$key,$value)
{
return [
"class" => "custom-control-input","id" => $key,];
},"choice_label_attr" => function($choice,$value)
{
return [
"class" => "custom-control-label","for" => $key,