我有一个问题,我想在同一控制器中使用两种形式 我有两种形式的此控制器,但问题是form1工作正常(返回新响应),但form2无法工作.. 该怎么解决?
public function fCandidat($id,Request $request)
{
$candidat = $this->getDoctrine()
->getRepository(Candidat::class)
->find($id);
$form = $this->createForm(CandidatType::class, $candidat);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
return new Response ("form1");
}
$defaultData = ['message' => 'Demandes candidats'];
$form2 = $this->createFormBuilder($defaultData)
->add('demandes', DemandeType::class)
->add('send', SubmitType::class)
->getForm();
$form2->handleRequest($request);
if ($form2->isSubmitted() && $form2->isValid()) {
{
return new Response ("form2");
}
return $this->render("index.html.twig",['form' => $form->createView(), 'form2' => $form2->createView()]);
}