0

I am having trouble making my multiple checkboxes list of Messages work. I want to be able to select few entries and delete/or move them to spam folder. I get stuck while trying to var_dump (for debugging purposes) content of data = $form->getData(), expression var_dump(data['id']) Prints like entire codebase of Symfony3 :D (which was for me totally unexpected) I based my code on Build a form having a checkbox for each entity in a doctrine collection and use Doctrine. This is the code

class MessageEntitySelectByIdentityType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder->add('id', EntityType::class, array(
        'required'      => false,
        'class'         => 'MonoDomainBundle:Message',
  //      'property'      => 'id',
        'property_path' => '[id]', # in square brackets!
        'multiple'      => true,
        'expanded'      => true
    ));
}

public function setDefaultOptions(OptionsResolver $resolver)
{
    $resolver->setDefaults(array(
        'data_class'      => Message::class,
        'csrf_protection' => false
    ));
}

}

public function mailboxAction(Request $request)
{
    $user = $this->getDoctrine()->getManager()->getRepository('MonoDomainBundle:User')->find(1);

$collection = $this->getDoctrine()->getRepository(Message::class)->getMyInbox($user);
$form = $this
    ->createForm(
        \Mono\DomainBundle\Form\MessageEntitySelectByIdentityType::class,
        $collection
    );
$form->add('spam', SubmitType::class);
$form->add('delete', SubmitType::class, ['label' => 'Trash']);

$form->handleRequest($request);
$this->addFlash('success', 'settings.simplified.general.text.success');

if ($form->isValid()) {

    $data = $form['id']->getData();
    var_dump($data);
Community
  • 1
  • 1
npower
  • 23
  • 4

1 Answers1

0

Using var_dump() on Doctrine entities goes to circular recursion by each relation.

That's why : Symfony provide a dump() function.

Alsatian
  • 3,086
  • 4
  • 25
  • 40
  • that makes sense, when i visited controller action using var_dump server hang out because was running out of memory, thanks for your help :) – npower Jul 26 '16 at 20:44