Symfony2将父实体ID设置为关系表

I have two entity Content and Synopsis, oneToOne relation. Content id is saved to synopsis table in content_id field. Both have different formtype class like: ContentType and SynopsisType.

now for reason I merged two forms like this way:

class ContentType extends AbstractType
{
/**
 * @param FormBuilderInterface $builder
 * @param array $options
 */
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('title','text',array('label'=>'Title'))
        ->add('bntitle','text',array('label'=>'Title 2'))
        ->add('unique_id','text',array('label'=>'Unique ID'))
        ->add('content_owner')
        ->add('sp_credits')
        ->add('synopsis',new SynopsisType())
 } }

Now i see the synopsis form in the content form but the problem I am facing is to save the content_id in the synopsis table. It is the Id from the content table to make relation of synopsis with its content.

can anyone tell me how can i get content id and set the value to synopsis table's content_id field?

Thanks

In doctrine if you want to add an object with another using foreign key you have to do this adding that object not only its id. So, get the content entity using content_id then add that content object to the synopsis entity.

  * @var \Bbd\BongoAppBundle\Entity\Synopsis
 */
private $synopsis;


/**
 * Set synopsis
 *
 * @param \Bbd\BongoAppBundle\Entity\Synopsis $synopsis
 * @return Content
 */
public function setSynopsis(\Bbd\BongoAppBundle\Entity\Synopsis $synopsis = null)
{
    $this->synopsis = $synopsis;

    return $this;
}

/**
 * Get synopsis
 *
 * @return \Bbd\BongoAppBundle\Entity\Synopsis 
 */
public function getSynopsis()
{
    return $this->synopsis;
}

putting this to the content entity solved the issue, i found that in symfony doc..