symfony/symfony — Issue #2431: Binding request to form gives a PHP fatal error
Author: egeloen
Created: 2011-10-18 22:09:06+00:00
State: open

I'm actually trying to set up a very simple form research. This form doesn't use a class.

My form class :

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

class SearchType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('search', 'text', array(
'label' => 'Research',
'max_length' => 100
));
}

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

My action which renders the research form :

public function searchAction()
{
$form = $this->createForm(new SearchType());

if($this->getRequest()->getMethod() === 'POST')
{
$form->bindRequest($this->getRequest());

if($form->isValid())
{

}
}

return array('form_search' => $form->createView());
}

When I execute this action, I have this error :

Fatal error: Call to a member function isTransient() on a non-object in /var/www/project.local/vendor/doctrine/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php on line 497

After some debug, I realize that it is the ``bindRequest`` method which generates the PHP fatal error.
I don't know if it is a mistake on my part or if it is a bug...