Personnalisé la liste des choix de sonata_type_model champ avec Sonata Admin

Je suis en utilisant Sonata Admin et j'ai un champ de catégories et j'ai besoin de les afficher dans l'ordre comme un arbre dans sélectionner:

<select>
    <option>Category father-1</option>
    <option>--Category child-1-1</option>
    <option>--Category child-1-2</option>
    <option>--Category child-1-3</option>
    <option>----Category child-1-3-1</option>
    <option>----Category child-1-3-2</option>
    <option>--Category child-1-4</option>
    <option>--...</option>
    <option>Category father-2</option>
</select>

C'est possible? Je l'ai essayé, y compris dans "choice_list' un tableau de générer dans getTreeCatsArray méthode:

protected function configureFormFields(FormMapper $formMapper)
{
    $tree_cat_array = $this->em->getRepository('MyBundle:Category')->getTreeCatsArray();

    $formMapper
        ->add('category', 'sonata_type_model', array(
                'empty_value' => '', 
                'choice_list' => $tree_cat_array)); 
}

Cela montre l'erreur:

The option "choice_list" with value "Array" is expected to be of type "null", "Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface"

Je ne sais pas si je doit utiliser le champ "type de sonata_type_model" ou "choix"

OriginalL'auteur Raúl | 2013-08-28