title: doctrine2: in a one-to-many bidirectional relationship, how to save from the inverse side?
body: <p>I have the One-to-Many bidirectional relationship below.</p>
  
  <p>After generating the crud actions with a symfony2 task, when I try to save the Products associated to a Category in the new/edit Category form, the products are not saved...</p>
  
  <pre class="lang-php prettyprint-override"><code>namespace Prueba\FrontendBundle\Entity;
  
  use Gedmo\Mapping\Annotation as Gedmo;
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  
  /**
   * @ORM\Entity
   * @ORM\Table(name="category")
   */
  class Category
  {
  
      /**
       * @var integer $id
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @ORM\OneToMany(targetEntity="Product", mappedBy="category")
       */
      protected $products;
  
      /**
       * @ORM\Column(name="name")
       */
      protected $name;
  
      public function __construct()
      {
          $this-&gt;products = new ArrayCollection();
      }
  
      public function getId()
      {
          return $this-&gt;id;
      }
  
      public function getName()
      {
          return $this-&gt;name;
      }
  
      public function setName($name)
      {
          $this-&gt;name = $name;
      }
  
      public function __toString()
      {
          return $this-&gt;name;
      }
  
      public function getProducts()
      {
          return $this-&gt;products;
      }
  
      public function setProducts($products)
      {
          die("fasdf"); //here is not entering
          $this-&gt;products[] = $products;
      } 
  
      public function addProduct($product)
      {
          die("rwerwe"); //here is not entering
          $this-&gt;products[] = $product;
      } 
  }
  </code></pre>
  
  <pre class="lang-php prettyprint-override"><code>namespace Prueba\FrontendBundle\Entity;
  
  use Gedmo\Mapping\Annotation as Gedmo;
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  
  /**
   * @ORM\Entity
   * @ORM\Table(name="product")
   */
  class Product
  {
      /**
       * @ORM\Id
       * @ORM\Column(type="integer")
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;
  
      /**
       * @ORM\ManyToOne(targetEntity="Category", inversedBy="products")
       * @ORM\JoinColumn(name="category_id", referencedColumnName="id")
       */
      protected $category;
  
      /**
       * @ORM\Column(type="string", length=100)
       */
      protected $name;
  
  
      public function getId()
      {
          return $this-&gt;id;
      }
  
      public function getName()
      {
          return $this-&gt;name;
      }
  
      public function setName($name)
      {
          $this-&gt;name =  $name;
      }
  
      public function getCategory()
      {
          return $this-&gt;category;
      }
  
      public function setCategory($category)
      {
          $this-&gt;category = $category;
      }
  
      public function __toString()
      {
          return $this-&gt;name;
      }
  }
  </code></pre>