Symfony Type error: Too few arguments to function FormRenderer::renderBlock()
12,155
The error comes from cached files, so in a first step, you should delete all files/dirs in /var/cache/.
Do it manually (not by console)
The form ending should be:
{{ form_end(form) }}
Related videos on Youtube

Author by
andreaem
I'm a FullStack PHP Developer from Italy, skilled in PHP,HTML, CSS, JS, jQuery. Develop with new technologies such as Angular, React and Vue.
Updated on June 09, 2022Comments
-
andreaem 7 months
I got a Form that must to handle the helpdesk requests in Symfony 3.3, i will render this using twig.
Controller
/** * @Route("/helpdesk/apri_ticket", name="helpdesk_apri") */ public function helpdeskNewAction(Request $request) { $entity = new HelpDesk(); $form = $this->createFormBuilder($entity) ->add('title',TextType::class,array( 'label' => 'Titolo', 'attr' => array('class' => 'form-control') )) ->add('type',ChoiceType::class, array( 'choices' => array( 'Scegli...' => '0', 'Assistenza' => '1', 'Problema' => '2', 'Errore' => '3' ) )) ->add('message', TextType::class, array( 'label' => 'Messaggio', 'attr' => array('class' => 'form-control') )) ->add('submit',SubmitType::class, array( 'label' => 'Apri Ticket', 'attr' => array('class' => 'btn-success') )) ->getForm(); $form->handleRequest($request); if($form->isSubmitted() && $form->isValid()) { print 'ok'; } return $this->render('help/help.create.html.twig', array( 'form' => $form->createView()) ); }
Here is the easy twig template:
{{ form_start(form) }} {{ form_widget(form.title) }} {{ form_widget(form.type) }} {{ form_widget(form.message) }} {{ form_end() }}
Here is the Error:
Type error: Too few arguments to function Symfony\Component\Form\FormRenderer::renderBlock(), 0 passed in /vendor/twig/twig/lib/Twig/Environment.php(462) : eval()'d code on line 83 and at least 2 expected
What's wrong with this? FormRenderer::renderBlock ask for at least 2 arguments, FormView and BlockName and optional an array containing variables. This is the first time I got this error and I don't know what is this BlockName.
-
andreaem over 5 yearsI've take this way but nothing changed, see the updated error shown that just change the file causing it. In addition i've disabled the cache for the twig environment
-
Michał G over 5 yearsand what happen if you try to render form by {{ form(form) }} in twig?
-
Michał G over 5 yearsand check form_end
-
andreaem over 5 yearsDamn, that was the error! Surely Symfony can explain better these errors.
-
Dariux about 5 yearsWhat if you do not have variable form? If you did not build form object, but used just plain html?