Showing posts with label naming. Show all posts
Showing posts with label naming. Show all posts

Wednesday, February 9, 2011

Form naming

Here is a short note, never forget to give your Form a name when calling Form::create:
# inside your controller

    public function formAction()
    {
        $context = $this->get('form.context');
        $request = $this->get('request');

        $form = MyForm::create($context, 'myform'); // 2nd parameter is the name of the form
        $form->bind($request);
  
        
        return $this->render('MyBundle:Index:form.html.twig', array(
            'form' => $form
        ));
    }

If you forget to pass a name the automatic token check will report everytime an error after submission.