Initialized in Controller, Null in Twig

时间:2015-06-30 13:44:13

标签: php symfony twig symfony-forms

I'm creating a form and passing the FormView to the template

$form = $this->createForm('my_user_form', $user);
die(get_class($form->createView()));
return $this->render('MyBundle::edit.html.twig', array(
    'form', $form->createView()
));

The die() gives me

Symfony\Component\Form\FormView

The dump() (from the template)

{{ dump(form) }}

gives me

null

How can this be explained ?

1 个答案:

答案 0 :(得分:0)

Thx again to @OIS, I was meaning

return $this->render('MyBundle::edit.html.twig', array(
    'form' => $form->createView()
));

instead of

return $this->render('MyBundle::edit.html.twig', array(
    'form', $form->createView()
));