title: Symfony2 form collection not calling addxxx and removexxx even if 'by_reference' => false
body: <p>I have the Customer entity and two one-to-many relations CustomerPhone and CustomerAddress.</p>
  
  <p>The Customer entity has addPhone/removePhone and addAddress/removeAddress "adders".</p>
  
  <p>CustomerType collections options has 'by_reference' => false for both collections.</p>
  
  <p>Entity functions addPhone/removePhone and addAddress/removeAddress not called after form submitted, so CustomerPhone and CustomerAddress have no parent id after persist. </p>
  
  <p>Why could addPhone/removePhone and addAddress/removeAddress not called on form submit?</p>
  
  <p><strong>UPD 1.</strong> </p>
  
  <p>After @Baig <a href="https://stackoverflow.com/questions/33358989/symfony2-form-collection-not-calling-addxxx-and-removexxx-even-if-by-reference#comment54516731_33358989">suggestion</a> now I have addPhone/removePhone "adders" called, but addAddress/removeAddress not. Can't get why because they are identical.</p>
  
  <pre><code> # TestCustomerBundle/Entity/Customer.php
  
   /**
   * @var string
   *
   * @ORM\OneToMany(targetEntity="CustomerPhone", mappedBy="customerId", cascade={"persist"}, orphanRemoval=true)
   */
  private $phone;
  
  /**
   * @var string
   *
   * @ORM\OneToMany(targetEntity="CustomerAddress", mappedBy="customerId", cascade={"persist"}, orphanRemoval=true)
   */
  private $address;
  </code></pre>
  
  <p>Same file "adders"</p>
  
  <pre><code># TestCustomerBundle/Entity/Customer.php
  /**
   * Add customer phone.
   *
   * @param Phone $phone
   */
  public function addPhone(CustomerPhone $phone) {
      $phone-&gt;setCustomerId($this);
      $this-&gt;phone-&gt;add($phone);
  
      return $this;
  }
  
  /**
   * Remove customer phone.
   *
   * @param Phone $phone customer phone
   */
  public function removePhone(CustomerPhone $phone) {
      $this-&gt;phone-&gt;remove($phone);
  }
  /**
   * Add customer address.
   *
   * @param Address $address
   */
  public function addAddress(CustomerAddress $address) {
      $address-&gt;setCustomerId($this);
      $this-&gt;address-&gt;add($address);
  
      return $this;
  }
  
  /**
   * Remove customer address.
   *
   * @param Address $address customer address
   */
  public function removeAddress(CustomerAddress $address) {
      $this-&gt;address-&gt;remove($address);
  }
  </code></pre>
  
  <p>Relations:</p>
  
  <pre><code># TestCustomerBundle/Entity/CustomerPhone.php
  /**
   * @ORM\ManyToOne(targetEntity="Customer", inversedBy="phone")
   * @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
   **/
  private $customerId;
  
  #TestCustomerBundle/Entity/CustomerAddress.php
  /**
   * @ORM\ManyToOne(targetEntity="Customer", inversedBy="address")
   * @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
   **/
  private $customerId;
  </code></pre>
  
  <p>CustomerType form:</p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder
          -&gt;add('name')
          -&gt;add('phone', 'collection', array(
              'type' =&gt; new CustomerPhoneType(),
              'allow_add' =&gt; true,
              'allow_delete' =&gt; true,
              'by_reference' =&gt; false,
              'options' =&gt; array('label' =&gt; false)
          ))
          -&gt;add('address', 'collection', array(
              'type' =&gt; new CustomerAddressType(),
              'allow_add' =&gt; true,
              'allow_delete' =&gt; true,
              'by_reference' =&gt; false,
              'options' =&gt; array('label' =&gt; false)
          ))
          -&gt;add('submit', 'submit')
      ;
  }
  </code></pre>
  
  <p>Controller.</p>
  
  <pre><code># TestCustomerBundle/Controller/DefaultController.php
  
  public function newAction(Request $request)
      {
          $customer = new Customer();
          // Create form.
          $form = $this-&gt;createForm(new CustomerType(), $customer);
          // Handle form to store customer obect with doctrine.
          if ($request-&gt;getMethod() == 'POST')
          {
              $form-&gt;bind($request);
              if ($form-&gt;isValid())
              {
                  /*$em = $this-&gt;get('doctrine')-&gt;getEntityManager();
                  $em-&gt;persist($customer);
                  $em-&gt;flush();*/
                  $request-&gt;getSession()-&gt;getFlashBag()-&gt;add('success', 'New customer added');
              }
          }
          // Display form.
          return $this-&gt;render('DeliveryCrmBundle:Default:customer_form.html.twig', array(
              'form' =&gt; $form-&gt;createView()
          ));
      }
  </code></pre>
  
  <p><strong>UPD 2.</strong>
  Test if addAddress called.</p>
  
  <pre><code>/**
       * Add customer address.
       *
       * @param Address $address
       */
      public function addAddress(Address $address) {
          jkkh; // Test for error if method called. Nothing throws.
          $address-&gt;setCustomerId($this);
          $this-&gt;address-&gt;add($address);        
      }
  </code></pre>
  
  <p><strong>UPD 3.</strong></p>
  
  <p>CustomerAddressType.php</p>
  
  <pre><code>&lt;?php
  
  namespace Delivery\CrmBundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  
  class CustomerAddressType extends AbstractType
  {
      /**
       * @param FormBuilderInterface $builder
       * @param array $options
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('street')
              -&gt;add('house')
              -&gt;add('building', 'text', ['required' =&gt; false])
              -&gt;add('flat', 'text', ['required' =&gt; false])
          ;
      }
  
      /**
       * @param OptionsResolverInterface $resolver
       */
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; 'Delivery\CrmBundle\Entity\CustomerAddress'
          ));
      }
  
      /**
       * @return string
       */
      public function getName()
      {
          return 'delivery_crmbundle_customeraddress';
      }
  }
  </code></pre>
  
  <p>CustomerPhoneType.php</p>
  
  <pre><code>&lt;?php
  
  namespace Delivery\CrmBundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  
  class CustomerPhoneType extends AbstractType
  {
      /**
       * @param FormBuilderInterface $builder
       * @param array $options
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('number')
          ;
      }
  
      /**
       * @param OptionsResolverInterface $resolver
       */
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; 'Delivery\CrmBundle\Entity\CustomerPhone'
          ));
      }
  
      /**
       * @return string
       */
      public function getName()
      {
          return 'phone';
      }
  }
  </code></pre>