Symfony2集合形成问题

时间:2013-07-22 11:50:33

标签: symfony symfony-forms

我正在使用symfony 2.3.2,我试图通过这种方式在我的表单类型上添加子元素

<?php

namespace candgo\EventoBundle\Form\Ajax;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use candgo\EventoBundle\Entity\Entrada;
use candgo\EventoBundle\Form\EntradaOrderType;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;


class EntradaAjaxType extends AbstractType
{

    protected $em,$id_evento;

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
      $builder->add('abc','collection');
      $builder->get('abc')->add('poc');
    }

    public function __construct($em,$id_evento)
    {
        $this->em=$em;
        $this->id_evento=$id_evento;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'show_legend' => false,
            ));
    }

    public function getName()
    {
        return 'purchase_tickets2';
    }

}

我也尝试过symfony doc

提供的代码示例
$builder->add('favorite_cities', 'collection', array(
    'type'   => 'choice',
    'options'  => array(
        'choices'  => array(
            'nashville' => 'Nashville',
            'paris'     => 'Paris',
            'berlin'    => 'Berlin',
            'london'    => 'London',
        ),
    ),
));

在两次追逐中,渲染的表格都是空的,有人知道会出问题吗?

0 个答案:

没有答案