Hi

I have the same issue.
In my case I have a `Category' that has a `parent' member that
references itself.

I solved this in the form by using the `entity' type for the
`parent' (check the documentation).

Although this solution isn't ideal it works.

On 17 Juni, 08:01, Bart <blauw...@gmail.com> wrote:
> Hi everyone.
>
> I'm having a rather odd problem which I suspect is either a bug or
> more likely I'm trying to do things the wrong way.I'd appreciate if
> you can shed a little light on the proper way to address this. Let me
> describe the issue.
>
> We have a container with the following ORM definition:
> Container:
>   type: entity
>   table: container
>   id:
>     id:
>       type: integer
>       generator:
>         strategy: AUTO
>     fields:
>       name:
>         type: string
>         length: 25
>     oneToMany:
>       children:
>         targetEntity: Container
>         mappedBy: parent
>    manyToOne:
>      parent:
>        targetEntity: Container
>        inversedBy: children
>       joinColumn:
>          name: parent_id
>          referencedColumnName: id
>
> And a FormType which looks as follows:
> use
>     Symfony\Component\Form\AbstractType,
>     Symfony\Component\Form\FormBuilder
>     ;
>
> class ContainerType extends AbstractType
> {
>     public function buildForm(FormBuilder $builder, array $options)
>     {
>         $builder
>             ->add('name', 'text')
>             ->add('children', 'collection', array(
>                 'type' => new ContainerType(),
>                 'prototype' => false,
>                 'allow_add' => true,
>                 'allow_delete' => true, ));
>
>     }
>
> }
>
> In the Controller we create a formBuilder by:
>                 $data = new Container();
>                 $form = $this->get('form.factory')->create(new
> ContainerType());
>                 $form->setData($data);
> ....etc...
>
> The form will crash with a:
> 'Fatal error: Maximum function nesting level of '100' reached,
> aborting! in /app/cache/dev/twig/15/ff/
> 401ed143a10a78a26e39b6e98c03.php on line 38'
> And a long stack trace showing the form recursing on itself.
>
> I looked at the code and I didn't see an easy way to stop the
> Container from rendering an infinite depth. What I'd really want is
> for it to throw out all the existing children from a parent but when a
> child does not exist not to create a prototype one....
>
> Obviously the buildForm method calls "new ContainerType" so that would
> be at the root of the issue. However I can't seem to pass
> "\ContainerType" as type.
>
> Can anyone shed a light on the correct way to do this?
>
> Thanks!

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to symfony-devs@googlegroups.com
To unsubscribe from this group, send email to
symfony-devs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to