sonata-project/SonataAdminBundle — Issue #415: Question about query into configureFormFields 
Author: mgws
Created: 2011-11-21 16:05:24+00:00
State: open

Hi, I have a many to many relations with a sonata_type_model type into the configureFormFields. I alredy modify the query for example:

$query = $this->modelManager->getEntityManager()->createQuery('SELECT s FROM My\Bundle\Entity\NegozioPrev s ORDER BY s.id DESC');

and then in $formMapper:

->add('idPrev', 'sonata_type_model', array('query' => $query))

all works fine and is good. Is it possibile to insert into $query a dynamic value like the ID of the same Entity?? Like this:

$id_neg = $this->getId();
$query = $this->modelManager->getEntityManager()->createQuery('SELECT s FROM My\Bundle\Entity\NegozioPrev s WHERE s.id = '.$id_neg.' ORDER BY s.id DESC');

The problem is that the $id_neg = $this->getId(); doesn't work.... is possible to get the ID of the Entity into the configureFormFields?