Php 以Symfony形式获取实体项

Php 以Symfony形式获取实体项,php,symfony,Php,Symfony,我有一个实体的选择,我需要得到它的属性在1标签。。例如: +---+-------+--------+--------------+ | | price | count | deliveryDate | +---+-------+--------+--------------+ | X | 100 | 6 | 2015-01-02 | +---+-------+--------+--------------+ | | 70 | 5 | 2015-02-

我有一个实体的选择,我需要得到它的属性在1标签。。例如:

+---+-------+--------+--------------+
|   | price |  count | deliveryDate |
+---+-------+--------+--------------+
| X |  100  |    6   | 2015-01-02   |
+---+-------+--------+--------------+
|   |   70  |    5   | 2015-02-03   |
+---+-------+--------+--------------+
如何在symfony中获取实体项?这是我的表单类型:

FormType.php:

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('name')
        ->add('Age')
        ->add('message', MessageType::class)
        ->add('choice', EntityType::class, array('class'=>'EspBundle\Entity\Choice',
            'multiple'=>true,
            'expanded'=>true,
            'query_builder'=> function(EntityRepository $er){
                return $er->createQueryBuilder('c')->orderBy('c.name','ASC');},
            ))
        ->add('Save', SubmitType::class)
    ;
}
那怎么可能是我的树枝文件呢?我尝试使用
{{form.label(form.choice.name)}
获取它们,但它不起作用


编辑1:这是我得到的结果

这里最简单的路线就是在字段上设置“选择标签”选项。因此:

->add('choice', EntityType::class, array('class'=>'EspBundle\Entity\Choice',
        'multiple'=>true,
        'expanded'=>true,
        'query_builder'=> function(EntityRepository $er){
            return $er->createQueryBuilder('c')->orderBy('c.name','ASC');},
        'choice_label' => 'name'
        ))

在twig中,您可以将其呈现为{{form_widget(form.choice)}或将整个表单呈现为{{form_widget(form)}

我按照您所说的做了,但它并不像我之前提到的那样出现,请参见我问题的编辑。您的一个实体是否有“name”test1和test2?在您的示例中,choice实体甚至没有名称列,所以我希望您希望输出一个不同的字段?