FriendsOfSymfony/FOSUserBundle — Issue #401: Persisting related entities
Author: dgorack
Created: 2011-11-11 00:53:31+00:00
State: open

I can't seem to get help through the mailing list or other places so I'm pointing my question here.

Using FOSUserBundle, I'm trying to persist related entities. I extended User with a new entity called UserInfo. When persisting using cascade function:

user_id column in the related userinfo entity is not being filled with the value of id from user entity upon registration:

User entity:

/**
* @ORM\Entity
* @ORM\Table(name="re_user")
*/
class User extends BaseUser
{
...

/**
* @ORM\OneToOne(targetEntity="UserInfo", mappedBy="user", cascade={"persist", "remove"})
*/
protected $userinfo;

User

class UserInfo
{
...

/**
* @ORM\OneToOne(targetEntity="User", inversedBy="userinfo")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;

...
}

What is the correct way to persist related FOSUserBundle entities.

I hope I've explained it well, please let me know if I can clarify further.