我的选择列表中的选择错误

时间:2016-07-11 13:11:00

标签: symfony doctrine-orm symfony-forms

使用symfony 2.7,我的网页中有两个不同的表单:

表单1:

public function buildForm(FormBuilderInterface $builder, array $options)
{
    /*
        $choices = array(
            0 => A (entity "Personne"),
            1 => B  (entity "Personne")
        )
     * 
     */
    $builder
        ->add('personne', 'entity', array(
            'class' => 'LogicielBundle:Personne',
            'choices' => $choices,
            'label' => 'Banque'
        ))
    ;
}

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

表格2

public function buildForm(FormBuilderInterface $builder, array $options)
{
    /*
        $choices = array(
            3 => C (entity "Personne"),
            4 => D (entity "Personne")
        )
     * 
     */
    $builder
        ->add('personne', 'entity', array(
            'class' => 'LogicielBundle:Personne',
            'choices' => $choices,
            'label' => 'Banque'
        ))
    ;
}

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

我的控制器:

    $form1 = $this->createForm('logiciel_remise_selection_form', null);
    $this->submit($form1);
    if($form1->handleRequest($request)->isValid()) {
        $remise = new Remise;
        $form2 = $this->createForm('logiciel_remise_form', $remise);
    }

但是在我的网页上是<选择>,for" form2",我有选择 A和B ... 这是" form1" 的选择O_O

当我转储()我的" form2"时,我有选择 C和D (好选择),但我有相同的" IdReader"在 choices_list (我不知道它是什么)与" form1" (https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php

你能帮助我吗?

0 个答案:

没有答案