I Sonata Admin bin mit und ich habe ein Feld von Kategorien und ich brauche sie, um wie ein Baum in ausgewählten zeigen:Benutzerdefinierte Auswahl Liste der sonata_type_model Feld mit Sonata Admin
<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>
Es ist möglich? Ich habe es versucht, auch in ‚choice_list‘ ein Array in getTreeCatsArray Verfahren erzeugen:
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));
}
Dies zeigt den Fehler:
The option "choice_list" with value "Array" is expected to be of type "null", "Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface"
Ich bin nicht sicher, ob ich Feldtyp ‚sonata_type_model‘ verwenden müssen, oder ' Wahl‘
Ich musste 'CompanyMyBundle: Category' verwenden. – Patrick
Ich habe versucht, aber es funktioniert nicht in meinem Fall – Kirit