4

I have a User entity and Address document. They are linked between each other with @gedmo\references doctrine extension. This relation works just fine. I can get both referenceMany and referenceOne linked objects.

Now i need to use it at the sonataUserBundle form to let user to add multiple addresses for the user. (user - in mysql, address - in mongodb).

I tried to use this in the userAdmin class:

  $formMapper->add('addresses', 'sonata_type_model', array(                    
                'class' => 'Application\Sonata\UserBundle\Document\Address',
                'required' => false,
                'expanded' => true,
                'multiple' => true
            ))

it gives me an error:

No entity manager defined for class Application\Sonata\UserBundle\Document\Address

Please, answer what should I do!

ArFeRR
  • 85
  • 1
  • 5
  • It seems that Sonata and gedmo\references don't work tegether just like that. check this issue: http://stackoverflow.com/questions/24391982/sonata-and-gedmo-references-doctrine-extension-doesnt-work-class-does-not-exi and try this bundle: https://github.com/prestaconcept/PrestaSonataGedmoDoctrineExtensionsBundle – tiriana Jul 24 '14 at 09:39
  • Have you tested the PrestaConcept bundle with Doctrine Extension Reference usage @tiriana ? I'm not sure if this is implemented that's why I asked for it: https://github.com/prestaconcept/PrestaSonataGedmoDoctrineExtensionsBundle/issues/6 – webDEVILopers Sep 10 '14 at 09:59
  • No, I have not, sorry. I haven't even try gedmo references. I only found some info and pasted a link. So unfortunately I cannot help. – tiriana Sep 10 '14 at 16:14
  • FYI @nicolas-bastien stated that the project is no longer maintained: https://github.com/prestaconcept/PrestaSonataGedmoDoctrineExtensionsBundle/issues/6 – webDEVILopers Sep 11 '14 at 12:43

1 Answers1

1

You get that error because a ModelManager of an Admin Class only supports the manager_type that you configured which is the ORM default. So it is looking for an entityManager.

I have a similar case but the other way around. Inside my Document Admin Class I have to link to an Entity. It works this way:

$formMapper->add('user', 'entity', array(
                'class'    => 'ApplicationSonataUserBundle:User',
                'label' => 'User'
            ));

You should simply be able to use entity and document as type instead of sonata_type_model.

webDEVILopers
  • 1,886
  • 1
  • 21
  • 35
  • Thanks for your answer it helps me too, but I still have a little bug is that when I update/create my entity this error appears : notice : Array to string conversion – Alouini Khalil May 21 '15 at 13:52