I have a entity `Centros.php` defined as follow:

```
<?php

namespace PI\CentroBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="centros")
 */
class Centros {

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="text")
     */
    protected $descripcion;

    public function getId() {
        return $this->id;
    }

    public function setDescripcion($descripcion) {
        $this->descripcion = $descripcion;
    }

    public function getDescripcion() {
        return $this->descripcion;
    }

}

```

And also has this another `UnidadesHasCentros.php` with this definition:

```
<?php

namespace PI\UnidadBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="unidades_has_centros")
 */
class UnidadesHasCentros {

    /**
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="PI\UnidadBundle\Entity\Unidades")
     * @ORM\JoinColumn(name="unidades_id", referencedColumnName="id")
     */
    protected $unidades_id;

    /**
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="PI\CentroBundle\Entity\Centros")
     * @ORM\JoinColumn(name="centros_id", referencedColumnName="id")
     */
    protected $centros_id;

    public function setUnidadesId(\PI\UnidadBundle\Entity\Unidades $unidad_id) {
        $this->unidades_id = $unidad_id;
    }

    public function getUnidadesId() {
        return $this->unidades_id;
    }

    public function setCentroId(\PI\CentroBundle\Entity\Centros $centros_id) {
        $this->centros_id = $centros_id;
    }

    public function getCentroId() {
        return $this->centros_id;
    }

}

```

This is my `CentroType.php` form and as yours can see I have the entity unmapped:

```
<?php

namespace PI\CentroBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class CentroType extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder
                ->add('unidades', 'entity', array('class' => 'PIUnidadBundle:Unidades', 'property' => 'descripcion', 'required' => false, 'multiple' => true, 'expanded' => false, 'mapped' => false, 'attr' => array('class' => 'form-control')))
                ->add('descripcion', 'text', array('attr' => array('class' => 'form-control')));
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            'data_class' => 'PI\CentroBundle\Entity\Centros'
        ));
    }

    public function getName() {
        return 'centro';
    }

}

```

When I create a new Centro I can assign Unidades without problem as follow:

```
public function createAction(Request $request) {
    $entity = new Centros();
    $form = $this->createForm(new CentroType(), $entity);
    $form->handleRequest($request);

    if ($form->isValid()) {
        $em = $this->getDoctrine()->getManager();
        $em->persist($entity);
        $em->flush();

        if ($request->get('unidades')) {
            foreach ($request->get('unidades') as $key => $value) {
                $entityUnidadesHasCentros = new UnidadesHasCentros();

                $entityUnidadesHasCentros->setCentroId($entity);
                $entityUnidadesHasCentros->setUnidadesId($value);

                $em->persist($entityUnidadesHasCentros);
            }
            $em->flush();
        }
    }

    return $this->redirect($this->generateUrl('listar-centros'));
}

```

But how I handle this from edit/update actions? I mean I need to get all the relation and display it in the edit form but don't know how to. If yours has a better solution let me know.