You shouldn't be persisting the Form itself, you should persist an Entity.

You need to bind the Form to the request, and pass it the Entity that you
want the Form values to be applied to. Read here for step by step
instructions:

http://symfony.com/doc/current/book/forms.html

On Fri, May 6, 2011 at 6:15 PM, Victor E. <vmmedin...@gmail.com> wrote:

> I decided to learn PHP through Symfony2, been doing fairly well so far
> but I can't seem to put together why I'm getting an an exception:
>
> "Class Symfony\Component\Form\Form is not a valid document or mapped
> super class."
> 500 Internal Server Error - MongoDBException
>
> When trying to persist form data to MongoDB in Symfony2 Beta 1.  I've
> determined that its either user failure or I believe Fabian mentioned
> that MongoDB MongoDBBundle won't work with Symfony 2 until Doctrine
> Common 2.1 is released due to lack of annotation support.
>
> The code that throws the exception is a simple form pretty much
> verbatim from the documentation:
>
>         $topicform = $this->get('form.factory')->create(new
> TopicPageType());
>
>        $request = $this->get('request');
>        if ($request->getMethod() == 'POST') {
>            $topicform->bindRequest($request);
>
>            if ($topicform->isValid()) {
>
>                $dm = $this-
> >get('doctrine.odm.mongodb.document_manager');
>                $dm->persist($topicform);
>                $dm->flush();
>
>                return $this->redirect($this-
> >generateUrl('_admin_secured_home'));
>
>            }
>
> Can someone please shed some light on this issue I've given it 2 days
> of my time.  I'd also like to keep developing using MongoDB so if
> there is a workaround please let it be known.  Thanks!
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to