1

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.

pgampe
  • 4,531
  • 1
  • 20
  • 31
Dean Collins
  • 233
  • 4
  • 13
  • I should note, when I say hangs; it pretty much freezes my browser. – Dean Collins Mar 23 '15 at 21:35
  • possible duplicate of [Too much data with var\_dump in symfony2 doctrine2](http://stackoverflow.com/questions/11902099/too-much-data-with-var-dump-in-symfony2-doctrine2) – Wirone Mar 23 '15 at 21:46

2 Answers2

1

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);.

Wirone
  • 3,304
  • 1
  • 29
  • 48
1

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

montexristos
  • 290
  • 2
  • 5