Symfony2收集表格问题
我使用的是symfony2.3.2,我正试图通过这种方式在我的表单类型上向集合中添加子元素Symfony2收集表格问题,symfony,symfony-forms,Symfony,Symfony Forms,我使用的是symfony2.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\EventoBundl
<?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';
}
}
在两次追逐中,渲染的表单都是空的,有人知道会有问题吗?您到底想实现什么?你的表单看起来怎么样?我正在尝试将几个自定义表单字段分组为“数组”
$builder->add('favorite_cities', 'collection', array(
'type' => 'choice',
'options' => array(
'choices' => array(
'nashville' => 'Nashville',
'paris' => 'Paris',
'berlin' => 'Berlin',
'london' => 'London',
),
),
));