i have an array with entities. I know that symfony has a collection type, but that what i want doesn't work as intended. I have created a FormType for a single entity and a FormType for the collection (formtype code for the collection):
$builder
->add('list', 'collection', array(
'label' => 'list',
'type' => new SingleItemType(),
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false
));
Now i have tried to create a Form
$arr = array(new Item(), new Item(), new Item());
$this->createForm(new CollectionListType(), $arr);
But this doesn't work; I get an error which means i should set "Item" as data_class, if i do this, an another error appears which means i should set data_class to null.
Another approach was to create a dummy entity which holds my array of Item-Entities but this doesn't works too.
Is there a simple approach to display a list of entities as collection form?
Greetings