Skip to content

Instantly share code, notes, and snippets.

@gmarquet
Created April 14, 2015 18:17
Show Gist options
  • Save gmarquet/2079d7790bf6f5f2fe10 to your computer and use it in GitHub Desktop.
Save gmarquet/2079d7790bf6f5f2fe10 to your computer and use it in GitHub Desktop.
class Formation
{
...
/**
* @Serializer\Exclude
* @ORM\OneToMany(targetEntity="FormationRequired", mappedBy="receiver" , cascade={"persist", "remove"} , orphanRemoval=true)
*/
private $formationRequireds;
/**
* Add formationRequireds
*
* @param \CIV\ApiBundle\Entity\FormationRequired $formationRequireds
* @return Formation
*/
public function addFormationRequired(\CIV\ApiBundle\Entity\FormationRequired $formationRequireds)
{
$this->formationRequireds[] = $formationRequireds;
$formationRequireds->setReceiver($this);
var_dump('addFormationRequired');
return $this;
}
}
class FormationType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('formationRequireds', 'entity', array(
'class' => 'Bundle:FormationRequired',
'property' => 'id',
'multiple' => true,
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('u')->orderBy('u.id', 'ASC');
}
))
;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment