In my model I have a Recipe entity and Ingredient entity. In Recipe entity, the relation is defined like this:
/**
* @ORM\\OneToMany(targetEntity=\"Ingredie
You need to use finishView method of your form type.
Here is the example of code:
public function finishView(FormView $view, FormInterface $form, array $options)
{
usort($view['photos']->children, function (FormView $a, FormView $b) {
/** @var Photo $objectA */
$objectA = $a->vars['data'];
/** @var Photo $objectB */
$objectB = $b->vars['data'];
$posA = $objectA->getSortOrder();
$posB = $objectB->getSortOrder();
if ($posA == $posB) {
return 0;
}
return ($posA < $posB) ? -1 : 1;
});
}