ciurciurek ciurciurek - 1 year ago 136
Twig Question

Symfony 3 don't send the form

I'm creating blog in Symfony 3.1.7 and i have a problem with sending the form. I created comment Entity Class. Then I generated form class by console end edited buildForm method. It looks like:

public function buildForm(FormBuilderInterface $builder, array $options)

My controller looks like this

* @Route("/article/{id}", name="show_article")
public function showAction( Post $post, Request $request )
$comment = new Comment;
$comment -> setPost($post);
$form = $this->createForm(CommentType::class);

if ($form->isSubmitted() ) {
$em = $this->getDoctrine()->getManager();
return $this->render('default/show.html.twig',[
'post' => $post,
'form' => $form -> createView()

Form is displayed by twig helper

And the problem is when i try to send form. I clicked on button
and nothing is happening. It looks like form was never subbmited.

Thanks for your help.

Answer Source

Use SubmitType like so:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download