I have a BookEntity (Name,Descript, ...) with a OneToMany relations to TagEntity(name, position)
A tag is linked to only one BookEntity and a BookEntity can have multiple Tags, but can also keep the Tags sorted in an explicit order.
For that I'm using an Drag&Drop javascript plugin in order to set a input field hidden into the TagType I have embed
$builder->add('tags','collection', array(
'type' => new TagType(),
'allow_add' => true,
'by_reference' => false,
'prototype' => true,
'allow_delete' => true)
);
I can add new Tag using prototype.
but I have existing tags, and I'm going into the Edit page of a BookType.
How can i specify the order of the TagType ?
Thanks a lot
referencing this issue and this one you can use doctrine's @OrderBy annotation to have the Tags ordered when fetched from database. This will affect the form-collection rendering aswell.
Just as a quick reminder you can order already fetched collections in your controller as described in my answer here.