0

In my Admin I'v defined this:

 protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper
    /* ... */
    ->add('camps', 'sonata_type_model', array(
        'btn_add'       => false,      //Specify a custom label
        'choices'        => $this->tema_service->getCampsDefinicio($this->getSubject()),
        'sortable'     => true,
        'multiple' => true,
            ), array(
                'placeholder' => 'No selected'
            ))

;
/* ... */
}

Function getCampsDefinicio returns an array of items ordered. Inspite of it, the options appear sorted according its id.

What can I do to get it respect the order given?

It does not care if I have to override any template. In that case which files I have to look for/override?

Oriol Planas
  • 107
  • 9

1 Answers1

0

Finally I solved this.

I was a little confused.

The order in the choises array is respected only for selectionable items.

The order for the SELECTED items is defined by te ArrayCollection provided in the entity function

/**
 * Get camps
 *
 * @return \Doctrine\Common\Collections\Collection
 */
public function getCamps()
{
   return $this->camps;
}
Oriol Planas
  • 107
  • 9