0
votes

I have a form in Sonata Admin with a couple of dropdown lists, each one should fill the next one with values from another Service (entity), is this possible?

1

1 Answers

0
votes
 protected function configureFormFields(FormMapper $formMapper)
 {

    $em = $this->modelManager->getEntityManager('YourBundleFile\YourBundleFileBundle\Entity\YourEntity');

    $qb = $em->createQueryBuilder();

    $qb = $qb->add('select', 'u')
            ->add('from', 'YourBundleFile\YourBundleFileBundle\Entity\YourEntity u');

    $query = $qb->getQuery();
    $arrayType = $query->getArrayResult();

$formMapper
->add('yourProperty', 'choice', array('choices'=>$arrayType))
-end();
}