3

I have this form which returns ArrayCollection

 $builder
    ->add('secondSubcategory', 'entity', array(
                'required'  => false,
                'class'    => 'AppBundle\Entity\SecondSubcategory',
                'choice_label' => 'name',
                'label' => false,
                'multiple' => true,
                'expanded' => true,
                ))
            ;

I'm working SyliusFormBundle and I want to set this result to session storage, like this

For displayAction:

$selected_categories = $context->getStorage()->get('second.subcategory');
$em = $this->getDoctrine()->getManager();
$selected_categories  =  $em->merge($selected_categories);

For forwardAction:

...
$em->detach($selected_categories);

but I've ArrayCollection, should I use entity object? serialize? or store only ids?

andreop
  • 51
  • 7

0 Answers0