symfony/symfony — Issue #2673: Return value of form type method getName() leads to infinite loop
Author: naitsirch
Created: 2011-11-18 12:06:49+00:00
State: open

Hi,
I have strange problem. When I am extending Symfony\Component\Form\AbstractType and I implement the method getName() and let it return always the string 'form', it will lead to an infinit loop in ***Symfony\Component\Form\FormFactory -> createNamedBuilder()***.

Here's my form type:

namespace Cnc\ProjectBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

class ProjectCreateType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('name', 'text');
$builder->add('customer_name', 'text', array('required' => false));
$builder->add('tags', 'text', array('required' => false));
}

public function getName()
{
return 'form';
}

public function getDefaultOptions(array $options)
{
return array(
'data_class' => 'Cnc\ProjectBundle\Entity\Project',
);
}
}

The infinite loop happens in the first **while** loop in the method ***createNamedBuilder(...)*** of class ***Symfony\Component\Form\AbstractType***.

It works fine if I change the return value of getName() to any other value.