Symfony 4-FormBuilder:在ChoiceType中使用“ choice_label_attr”吗?

在我的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,
wyuan123 回答:Symfony 4-FormBuilder:在ChoiceType中使用“ choice_label_attr”吗?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2698204.html

大家都在问