Le 07/05/2011 21:25, Victor E. a écrit :
On May 7, 11:31 am, Donald Tyler<chekot...@gmail.com>  wrote:
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
Thanks a lot Donald. My mistake was that since $topicform is validated
through the isValid() method, I thought that form contained data which
I could persist directly.

I have since changed the "if ($topicform->isValid())" method to:

    if ($topicform->isValid()) {

                 $topic = new Topic();
                 $arrayvar =  $request->get('arraykey');


                 $topicgetvar = $arrayvar['Topic'];


                 $topic->setTopic($topicgetvar);


                 $dm = $this->get('doctrine.odm.mongodb.document_manager');
                 $dm->persist($topic);
                 $dm->flush();

                 return 
$this->redirect($this->generateUrl('_admin_secured_home'));
}

Everything seems to be working correctly now.

What you should be persisting is $form->getData if you are using the document as domain object of the form. You should not redo the job by setting the parameters yourself as it basically means that you are handling the form by hand.

--
Christophe | Stof

--
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