This may be a basic question, but I am new to Symfony and clueless at the moment. I have a many to many relation, where 2 tables are linked by a third, which contains the primary key of the initial 2 tables.
I generated the CRUD with generate:doctrine:crud.
When I am creating data in the first table (table 1) I have a listbox with many entries from second table (table 2). It is really a big list and many entries can be selected by pressing CTRL. Really hard with the huge list, but it works beautifully. All tables are being populated nicely.
I would like to sort the list box by name ASC, but have not so far found a way of doing it. Any help would be greatly appreciated.
The code was completely generated by Symfony2. When it creates an instance for the first entity (table 1), in its construct method it gathers data from table 2 to present the listbox:
$this->table2id = new \Doctrine\Common\Collections\ArrayCollection();
This is what I understood, but how is this data being selected and how can I sort it?
Cheers, Erick
UPDATE:
I found in the documentation that @ORM\OrderBy would do the trick, but it does not seem to be working for me. Anyone can spot an error in this annotation?
`/**
* @var \Doctrine\Common\Collections\Collection`
*
* @ORM\ManyToMany(targetEntity="Suburb", inversedBy="workerid")
* @ORM\JoinTable(name="workersuburb",
* joinColumns={
* @ORM\JoinColumn(name="WorkerID", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="SuburbID", referencedColumnName="id")
* }
* )
* @ORM\OrderBy({"SuburbID"="DESC"})
*/
private $suburbid;`