Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 提交表格Symfony 2时出错_Php_Symfony - Fatal编程技术网

Php 提交表格Symfony 2时出错

Php 提交表格Symfony 2时出错,php,symfony,Php,Symfony,请有人告诉我为什么我会出错 public function trainingAction() { $em = $this->getDoctrine()->getManager(); $Date = new AcademyTraining(); $Date->setDate(new \DateTime('tomorrow')); $Time = new AcademyTraining(); $Time->setTime();

请有人告诉我为什么我会出错

public function trainingAction()
{
    $em = $this->getDoctrine()->getManager();

    $Date = new AcademyTraining();
    $Date->setDate(new \DateTime('tomorrow'));
    $Time = new AcademyTraining();
    $Time->setTime();
    $Topics = new AcademyTraining();
    $Topics->setTopics('');
    $Leader = new AcademyTraining();
    $Leader->setLeader('');
    $Details = new AcademyTraining();

    $Dateform = $this->createFormBuilder($Date)
        ->add('date', DateType::class, array(
            'label' => false,
            )
        )
        ->getForm();

    $Timeform = $this->createFormBuilder($Time)
        ->add('time', TimeType::class, array(
            'input'  => 'datetime',

            'label' => false,
            )
        )
        ->getForm();

    $Topicsform = $this->createFormBuilder($Topics)
        ->add('Topics', TextType::class, array(
            'label' => false,
            )
        )
        ->getForm();

    $Leaderform = $this->createFormBuilder($Leader)
        ->add('Leader', ChoiceType::class, array(
            'choices' => array(
                'name' => 'Name',
                'name2' => 'Name 2'
            ),
            'label' => false,
            )
        )
        ->getForm();


    $SessionSubmitForm = $this->createFormBuilder($Details)
        ->add('save', SubmitType::class, array( array('label' => 'Save Changes'))
        )
        ->getForm();

    $user = $this->get('security.token_storage')->getToken()->getUser();
    $applicantstatus = $user->getApplicantStatus();



    if ($SessionSubmitForm->isSubmitted() && $SessionSubmitForm->isValid()) {

        $Details = $Leaderform->getData();
        $Details = $Dateform->getData();
        $Details = $Timeform->getData();
        $Details = $Topicsform->getData();

        $em = $this->getDoctrine()->getManager();
        $em->persist($Details);
        $em->flush();

        return $this->redirectToRoute('task_success');
    }

    return $this->render('AppBundle:Academy/Applicants:trainingPTSpage.html.twig', array(
        'Timeform' => $Timeform->createView(),
        'Topicsform' => $Topicsform->createView(),
        'Dateform' => $Dateform->createView(),
        'Leaderform' => $Leaderform->createView(),
        'officers' => $em->getRepository('AppBundle:TrainingParticipants')->findAll(),
        'session' => $em->getRepository('AppBundle:AcademyTraining')->findAll(),
        "applicantstatus" => $applicantstatus

    ));

}
错误是:

选项“0”不存在。定义的选项有:“属性”、“自动初始化”、“块名称”、“禁用”、“标签”、“标签格式”、“翻译域”、“验证组”


此表格用于阅读培训课程的详细信息。它使用Symfony生成表单。我为每个字段分别制作了表格。我相信我可能有格式错误的形式和他们的属性,但我不确定这是错误的原因

如果有多维数组,则必须声明关联数组,如下所示:

$SessionSubmitForm = $this->createFormBuilder($Details)
    ->add('save', SubmitType::class, array('label' => 'Save Changes')
    )
    ->getForm();