PUGX / PUGXMultiUserBundle

An extension for FOSUserBundle to handle users of different types. Compatible with Doctrine ORM.
163 stars 96 forks source link

Expected argument of type "string", "AppBundle\Form\Type\RegistrationUserOneFormType" given #110

Closed saddem0 closed 8 years ago

saddem0 commented 8 years ago

need help, i followed the installation instructions but i get this error when accesing "register/user-one"

garak commented 8 years ago

Can you provide a stack trace of your exception?

saddem0 commented 8 years ago

[1] Symfony\Component\Form\Exception\UnexpectedTypeException: Expected argument of type "string", "AppBundle\Form\Type\RegistrationUserOneFormType" given at n/a in C:\wamp\www\test\vendor\symfony\symfony\src\Symfony\Component\Form\FormFactory.php line 80

at Symfony\Component\Form\FormFactory->createNamedBuilder('fos_user_registration_form', object(RegistrationUserOneFormType), null, array('validation_groups' => array('Registration', 'Default')))
    in C:\wamp\www\test\vendor\symfony\symfony\src\Symfony\Component\Form\FormFactory.php line 47

at Symfony\Component\Form\FormFactory->createNamed('fos_user_registration_form', object(RegistrationUserOneFormType), null, array('validation_groups' => array('Registration', 'Default')))
    in C:\wamp\www\test\vendor\pugx\multi-user-bundle\PUGX\MultiUserBundle\Form\FormFactory.php line 65

at PUGX\MultiUserBundle\Form\FormFactory->createForm()
    in C:\wamp\www\test\vendor\friendsofsymfony\user-bundle\Controller\RegistrationController.php line 52

at FOS\UserBundle\Controller\RegistrationController->registerAction(object(Request))
    in C:\wamp\www\test\vendor\pugx\multi-user-bundle\PUGX\MultiUserBundle\Controller\RegistrationManager.php line 64

at PUGX\MultiUserBundle\Controller\RegistrationManager->register('AppBundle\Entity\UserOne')
    in C:\wamp\www\test\src\AppBundle\Controller\RegistrationUserOneController.php line 12

at AppBundle\Controller\RegistrationUserOneController->registerAction()
    in  line 

at call_user_func_array(array(object(RegistrationUserOneController), 'registerAction'), array())
    in C:\wamp\www\test\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php line 139

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
    in C:\wamp\www\test\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php line 62

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
    in C:\wamp\www\test\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php line 169

at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
    in C:\wamp\www\test\web\app_dev.php line 30
garak commented 8 years ago

You're passing a form object to createForm. You must pass the name of the class, not the object itself. E.g.: RegistrationUserOneFormType::class

saddem0 commented 8 years ago

in services.yml or config.yml? because that's the only place where "AppBundle\Form\Type\RegistrationUserOneFormType" is mentioned.

garak commented 8 years ago

Looks like you're using Symfony 3. I'm afraid that that is not supported, for now.

saddem0 commented 8 years ago

Yes i use symfony 3, thanks anyway.

fdonzello commented 8 years ago

If you want to fix this just go to this file: https://github.com/PUGX/PUGXMultiUserBundle/blob/master/Model/UserDiscriminator.php#L146

and for method getFormType($name) just return the $className var.