Symfony2 forms embed mongodb document into sql entity

Go To StackoverFlow.com

1

I need little help :). Here is the situation. I am using symfony2 + FOSUserBundle, I made my forms custom, so far so good. I have User registration with user information in the custom registration form (like first name, last name, birth date etc). Now I decided that it will be more practical to make the user info to be stored in mongodb as document (as I probably will add more information to users later). I built the user info form, and successfully embedded it to the user form. Now the problem is that I cannot set Document object inside Entity object - symfony tells me that the object must be an Entity.

/**
 * Acme\UserBundle\Entity\User
 *
 * @ORM\Table(name="user")
 * @ORM\Entity
 */
class User extends BaseUser
{
    /**
     * @Assert\Type(type="Acme\UserBundle\Document\UserInfo") 
     */
    protected $userinfo;

I want to ask, what is the proper way to do this ? Sure I can get the needed information form the request as an array and fill in the user info object ... but it looks ugly and wrong :) so how it must be done ? Thanks.

2012-04-04 07:42
by zlat


0

I assume you extends the entity class

FOS\UserBundle\Entity\User

there is a document class provided by the bundle

FOS\UserBundle\Document\User

You could extends this one

2012-04-04 09:06
by Julien Rollin
That's right, I am extending the Entity class, but this is exactly what I want... I need this basic user info as username, password and email to be Entity I will use it in relational schema. But the information like first name, last name etc I want to store as document - zlat 2012-04-04 10:32
Ads