Missing documentation in nested collections
In reference to issue #858 there is a missing documentation for nested collections. The problem is not in the Javascript as is mention in the issue #858. There is a configuration problem.
When you have nested collections you have to set the attr data-widget-controls to "true"
This will change the itemSelector in the Javascript and then will use div.collection-id. > .collection-items > .collection-item instead of div.collection-id. > .collection-item
So an example of the FormType will be something like this:
<?php
//Collection1Type.php
...
class Collection1Type extends AbstractType
{
public function buildForm (FormBuilderInterface $builder, array $options)
{
$builder
->add('field_name', 'collection', array(
'type' => new Collection2Type(),
'allow_add' => true,
'allow_delete' => true,
'prototype_name' => '__collection1block__',
'attr' => array(
'data-widget-controls' => 'true'
)
))
}
....
}
<?php
//Collection2Type.php
...
class Collection2Type extends AbstractType
{
public function buildForm (FormBuilderInterface $builder, array $options)
{
$builder
->add('field_name', 'collection', array(
'type' => new Collection3Type(),
'allow_add' => true,
'allow_delete' => true,
'prototype_name' => '__collection3__',
'attr' => array(
'data-widget-controls' => 'true'
)
))
}
....
}
<?php
//Collection3Type.php
...
class Collection3Type extends AbstractType
{
public function buildForm (FormBuilderInterface $builder, array $options)
{
$builder
->add('name')
->add('email', 'email')
}
....
}
@aferrandini Can you please create that doc as a PR?
Sure, let me have some free time to do that :)
ping @aferrandini :-)
Sorry I had not time to do it, I'll try to work on that this week.
That would be great, thanks