I have a form in Symfony2 that needs to have an entity selection field populated by the Players collection in a specific tournament. I create a Type form and pass the tournament identifier to the query_builder property of the correct field. In the object repository, I have this method:
public function allPlayersInTournamentQuery($tournament_id) { $repo = $this->getEntityManager()->getRepository('GameBundle:Tournament'); $tournament = $repo->find($tournament_id); $players = $tournament->getPlayers(); $playersIds = array(); foreach ($players as $player) { $playersIds[] = $player->getId(); } $playersQuery = $this->createQueryBuilder('p') ->in('p.id', $playersIds) ->orderBy('p.real_name', 'ASC'); return $playersQuery; }
The function in () does not exist in the query builder. Hope the method shows what I'm trying to do. Im binding to return a query builder who selects the correct players found in this tournament.
How can i achieve this?
Thanks!
source share