0

I have created a form in symfony2:

    $form = $this->createFormBuilder()
        ->add('name', 'text')
        ->getForm();

    return $this->render('SixStringPearBundle:Icon:form.html.twig', array("form" => $form->createView()));

When i go to render: {{ form(form) }}

I get the following error:

The function "form" does not exist. Did you mean "form_row", "form_rest", "form_label", "form_errors", "form_widget", "form_enctype" in SixStringPearBundle:Icon:form.html.twig at line 1

I have also tried using:

{{ form_start(form) }}
{{ form_errors(form) }}

{{ form_row(form.name) }}

<input type="submit" />
{{ form_end(form) }}

And I get the following error: The function "form_start" does not exist in SixStringPearBundle:Icon:form.html.twig at line 1

Any thoughts as to why this may be happening?

3
  • 2
    Pretty sure you are running a version < 2.3 Commented Jun 6, 2013 at 19:42
  • Yep just realized that :).. I'm running 2.2. Thanks Commented Jun 6, 2013 at 19:44
  • I'm facing same issue and I have used symfony3.3.5 version but getting same error while rendering the form in twig. Error: An exception has been thrown during the rendering of a template ("No block "form_start" found while rendering the form.") Can you please tell me what is wrong with this? Commented Aug 22, 2017 at 5:51

2 Answers 2

1

The function was changed from form_widget() to form() in symfony2.3. I am using symfony2.2 and was reading the wrong docs

Sign up to request clarification or add additional context in comments.

Comments

0

Which version of S2 are you using? Did you change anything in app/config/config.yml?

I suspect that maybe you had a typo somewhere and kept having issues trying to fix it. Reduce your form.html.twig file to just one line:

{{ form(form) }}

Unless you somehow managed to disable the twig bridge FormExtension then it should see the form function.

==================

@cheesemacfly is correct. form() was added to 2.3. When looking at the documentation, select the correct version in the upper right hand corner. Better yet, start over with S2.3.0. No point in working with older versions.

1 Comment

"Starting over" is usually not an option, upgrading is. Also, 2.2 is still supported for a while. I still have a few 2.0 and 2.1 project running live, that I won't be able to upgrade in the foreseeable future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.