eZ Platform Discussions

[Netgen EzFormsBundle] I can't get it to work


#1

I want to use this bundle to allow my Internet users to create “contact” type objects under a “form” type page.

class FormController extends Controller
{
    /*
                form:
                    controller: "MyBundle:Form:full"
                    template: "MyBundle:full:form.html.twig"
                    match:
                        Identifier\ContentType: [form]
    */
    public function fullAction(Request $request, ContentView $view)
    {
        $repository = $this->getRepository();
        $contentService = $repository->getContentService();

        $contentType = $this->getRepository()->getContentTypeService()->loadContentTypeByIdentifier( "contact" );
        $contentCreateStruct = $contentService->newContentCreateStruct( $contentType, 'fre-FR' );

        $data = new DataWrapper( /*ContentCreateStruct*/$contentCreateStruct, /*ContentType*/$contentType /*No target for create content*/);

        /** @var FormBuilder $formBuilder */
        $formBuilder = $this->container
            ->get( "form.factory" )
            ->createBuilder( "ezforms_create_content", $data );
}

Could not load type “ezforms_create_content”: class does not exist.


#2

Simply replace classe name by Class::class

    /** @var FormBuilder $formBuilder */
    $formBuilder = $this->container
        ->get( "form.factory" )
        ->createBuilder( CreateContentType::class, $data );

    // Adding controls as EzFormsBundle does not do that by itself
    $formBuilder->add( "save", SubmitType::class, array( "label" => "Envoyer" ) );

#3

ping @MarioBlazek :slight_smile: