Reputation: 243
I am trying to create a simple search form that uses an entity type to create the form.
private function createCreateForm()
{
return $this->createFormBuilder()
->setAction($this->generateUrl('search_results'))//->add('search', 'search')
->add('professions','entity', array(
'class' => 'AppBundle:Profession',
'property' => 'name',
'multiple' => true,
'expanded' => true))
->add('submit', 'submit')
->getForm();
}
This work perfectly and my form has the checkboxes created from my database records.
However, when I try to handle the request on POST - it just hangs and does nothing!
public function resultAction(Request $request)
{
$form = $this->createCreateForm();
$form->handleRequest($request);
$professions = $form->getData();
print_r($professions);
}
All I wanted to retrieve was an array of the select options so I could perform a search query with them.
If I just create an array of values, it works fine which makes me wonder if it is hanging as it attempts to resolve the entity relationship on handleRequest()?
Any ideas would be greatly appreciated!
Thanks.
Upvotes: 1
Views: 101
Reputation: 290
As of Symfony 2.6 there is the VarDumper component's dump() function that will work fine with Doctrine objects
see here for more details: http://symfony.com/blog/new-in-symfony-2-6-vardumper-component
Upvotes: 1
Reputation: 3373
The output data is too big. Try print_r($professions[0]);
or, if $professions
is an ArrayCollection
, print_r($professions->first());
. You can also use \Doctrine\Common\Util\Debug::dump($professions);
.
Upvotes: 1