eZ Community » Forums » eZ Publish 5 Platform » Ez5 - Symfony Forms
expandshrink

Ez5 - Symfony Forms

Ez5 - Symfony Forms

Thursday 21 February 2013 9:02:48 am - 4 replies

Hey Guys,

is it possible, to create forms in Ez5 the Symfony way (see http://symfony.com/doc/current/book/forms.html)? At the moment, I always get following exception:

 An exception has been thrown during the rendering of a template ("Unable to render the form as none of the following blocks exist: "_form_widget", "form_widget".")...

I created the form with following simple code (as shown in http://symfony.com/doc/current/book/forms.html#using-a-form-without-a-class):

 

Controller:

use eZ\Bundle\EzPublishCoreBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
 
class DefaultController extends Controller
{
    public function indexAction()
    {
        $form = $this->createFormBuilder( array('message' => 'Type message here') )
            ->add('name', 'text')
            ->add('email', 'email')
            ->add('message', 'textarea')
            ->getForm();
 
        return $this->render(
            'MyAwesomeBundle::content.html.twig',
            array( 'form' => $form->createView())
        );
    }
} 

In the template, I dumped the form object using dump(form) template function and received a valid object from Symfony\Component\Form\FormView. But when I try to render the object using form_widget(form), the mentioned exception appears.

I saw the other Forms Thread (http://share.ez.no/forums/ez-publish-5-platform/ez5-create-a-form ) but it didn't answer my question, since as far as I understood, the OP created the HTML form and retrieving of POST values from scratch.What is my mistake?

Or is it impossible at the moment, to create standard Symfony forms?

Thanks in advance, regards!

Ryad

Modified on Friday 22 February 2013 8:21:59 am by Nicolas Pastorino

Thursday 21 February 2013 10:13:57 pm

Hey ! 

I got the same problem and this is the response : http://share.ez.no/forums/ez-publish-5-platform/ez5-create-a-form

That's why I started building the form from scratch but I had Type problem so I did it without Symfony help : https://jira.ez.no/browse/EZP-20473.

I didn't understand why exactly it's not working because it's Symfony basics... : Twig version or this method (form_widget) is not available...?

Good luck

Thursday 07 March 2013 10:43:14 am

Hi.

I think your mistake is somewhere else. I have a form just like yours and it works fine.

I also to pasted your code in my own controller and redered it using form_widget and it works.

I am sorry but I didn't run in this problem so I do not see how to help you. But it seems there is no mistake in your code.

Friday 15 March 2013 10:52:41 am

Thanks for your reply Julien Montavit. I'm not sure, why this problem appears. I tried that code in an 5.0.0 EE environment with no special modifications. As our CEO asked a few eZ employees about that Symfony form issue on the last eZ conference in Cologne, it seems to be not completely discussed by eZ either to fully support Symfony forms or to implement something more eZ specific (if I'm informed correctly).

Nevertheless I'm currently using forms from scratch and read the post values using $request->getParameter() method for the moment.

Friday 29 March 2013 10:24:07 am

Hey guys,

I tried it again with the current eZ CE 2013.1 and it works. It seems to be a problem with the eZ EE 5.0. I will retry this issue with the EE 5.1 beta, when it's released.

Thanks for your help.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from