symfony 获取选择的 choiceType 值

symfony get selected choiceType value

您好,我正在研究 symfony 3.3 项目。我有一个带有 choiceType 的表单,我想知道读取所选选项的正确方法是什么

控制器代码

$form = $this->createFormBuilder()
        ->add('decision', ChoiceType::class, array('choices'  => array(
        'valider' => 'valider',
        'rejeter' => 'rejeter',
    )

    ))
        ->setAction($this->generateUrl('validerRejeter', array('id' => $cours->getId())))
        ->setMethod('POST')
        ->getForm();

  $form->handleRequest($request); 
  if ($form->isSubmitted() && $form->isValid())
  {
    $choix=$request->request->get('form');
    if ($choix == 'valider')
        $cours->setEtat('publié');
    else 
        $em->remove($cours);
        $em->flush();
    }
$choix = $form->get('decision')->getData();

$choix = $request->request->get('decision');