Hi,
if I use sonata_type_collection like this:
$formMapper
->add('galleryHasMedias', 'sonata_type_collection', array(
'by_reference' => false,
'label' => 'Attached Media'
), array(
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'position',
'link_parameters' => array('context' => 'amenity')
))
Changing sorting and updating object works. The problem is that when I open an Edit form and there is a list of galleryHasMedias it's not sorted by current position values. So actually I don't know what position has each of the object.
Cannot reproduce the current code with the SonataMediaBundle works fines.
thomas2411, i think you just need to add
Indeed it worked shtumi :) Thank you very much. Although I have used YML mapping:
oneToMany:
galleryHasMedias:
targetEntity: PhotoGalleryMedia
mappedBy: gallery
cascade: ["persist", "remove"]
orphanRemoval: true
orderBy: {position: ASC}
Omg... thanks @shtumi
Most helpful comment
thomas2411, i think you just need to add
to your OneToMany relation in entities.
For me it works fine.