Symfony2 - 在表单中使用不同的类

时间:2014-04-07 10:49:31

标签: forms symfony doctrine

我正在尝试在表单中添加两个类。所以我为第二堂课做了:

            foreach ($formOwnersDetails as $i => $details) {
                $form = $form->add("member_{$i}_has_voting_denied", 'checkbox', array(
                    'data_class' => 'Pro\ConvocationBundle\Entity\OwnerDetails',
                    'property_path' => "votingDenied",
                    'label' => ' ',
                    'required' => false
                ));

但它给了我一个错误:

Neither property "votingDenied" nor method "getVotingDenied()" nor method "isVotingDenied()" exists in class "Pro\ConvocationBundle\Entity\Convocation" 

为什么在字段定义中添加Pro\ConvocationBundle\Entity\Convocation时会找到data_class

1 个答案:

答案 0 :(得分:0)

我没有检查它但它应该工作: 有关详细信息,请查看文档entity

  $form = $form->add("member_{$i}_has_voting_denied", 'entity', array(
                'class' => 'Pro\ConvocationBundle\Entity\OwnerDetails',
                'property' => "votingDenied",
                'label' => ' ',
                'required' => false
            ));