Sonata Admin Bundle One-to-Many relationship not saving foreign ID

前端 未结 6 1333
粉色の甜心
粉色の甜心 2020-12-14 12:23

I have a problem with the SonataAdminBunle in combination with symfony 2.2. I have a Project entity and a ProjectImage entity and specified a One-to-Many relationship betwee

6条回答
  •  无人及你
    2020-12-14 13:12

    the simplest solution is, and naturally replace your variable names; this works for me: 'by_reference' => false

    as follows:

    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('name')
            ->add('articles', EntityType::class, array(
                'class' => 'EboxoneAdminBundle:Article',
                'required' => false,
                'by_reference' => false,
                'multiple' => true,
                'expanded' => false,
            ))
            ->add('formInputs', CollectionType::class, array(
                'entry_type' => FormInputType::class,
                'allow_add' => true,
                'allow_delete' => true,
                'by_reference' => false,
            ))
        ;
    }
    

提交回复
热议问题