Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing documentation in nested collections #977

Open
aferrandini opened this issue Nov 20, 2014 · 5 comments
Open

Missing documentation in nested collections #977

aferrandini opened this issue Nov 20, 2014 · 5 comments

Comments

@aferrandini
Copy link
Contributor

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')      
    }
    ....
}
@phiamo
Copy link
Owner

phiamo commented Jan 12, 2015

@aferrandini Can you please create that doc as a PR?

@aferrandini
Copy link
Contributor Author

Sure, let me have some free time to do that :)

@phiamo
Copy link
Owner

phiamo commented May 30, 2015

ping @aferrandini :-)

@aferrandini
Copy link
Contributor Author

Sorry I had not time to do it, I'll try to work on that this week.

@phiamo
Copy link
Owner

phiamo commented Jun 11, 2015

That would be great, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants