实体类型的期望值,得到的是 "integer"。输入失败

Expected value of type Entity, got "integer" instead. Type fails

我正在创建一个表单,其中有一个单选按钮,其中我 select 人的性别。但是当我保存表单时,它总是抱怨它没有收到它所欠类型的变量。我的问题是,正如我在表格中指出的那样,RadioButton 必须采用实体“...\PersonBundle\Entity\Sex”的实例,将 'class' => '...\PersonBundle\Entity\Sex' , 不行,'class' 不承认它是一个选项。

代码:

->add('id_sex', ChoiceType::class,
            array(
                'required' => false,
                'label'     => 'Sex:',
                'choices'  =>
                    array(
                        '1' => 'Man',
                        '2'  => 'Woman',
                    ),
                'expanded' => true,
                'multiple' => false
            )
        )

我已经让它工作了,它是与之对应的类型,它不是错误。我按照以下方式生成了它,并且在我的情况下效果很好。

->add('id_sex','entity',
                array(
                    'required'      => false,
                    'class'         => '...\PersonBundle\Entity\Sex',
                    'empty_value'   =>  null,
                    'label'         => 'Sex',
                    'property'      => 'descripcion',
                    'expanded'      =>  'expanded',
                    'attr'          =>
                        array(
                            'class' =>'radiobutton-container'
                        )
                )
            )