I want to provide different login/register pages/forms for my users, but the users are the same class. I don't want to populate the database with additional tables.
pugx_multi_user:
users:
medics:
entity:
class: MedAppBundle\Entity\User
registration:
form:
type: MedAppBundle\Form\MedicRegistrationType
name: app_medics_registration
validation_groups: [Registration, Default]
template: MedAppBundle:Registration:registerMedic.html.twig
profile:
form:
type: MedAppBundle\Form\ProfileType
validation_groups: [Profile, Default]
patients:
entity:
class: MedAppBundle\Entity\User
registration:
form:
type: MedAppBundle\Form\PatientsRegistrationType
template: MedAppBundle:Registration:registerPacient.html.twig
profile:
form:
type: MedAppBundle\Form\ProfileType
validation_groups: [Profile, Default]
And here is the registration class :
class RegController extends Controller
{
public function registerPatientAction()
{
return $this->container
->get('pugx_multi_user.registration_manager')
->register('MedAppBundle\Entity\User');
}
public function registerMedicAction()
{
return $this->container
->get('pugx_multi_user.registration_manager')
->register('MedAppBundle\Entity\User');
}
Unfortunately the forms all end up as the last type of user, namely pacients. This configuration doesn't work mainly because UserDiscriminator
takes values by class instead of user type names.
Is there any kind of configuration that helps or does anyone have any kind of idea how I can achieve this?
Don't use PuGXMultiUserBundle
for your needs it does not make sense.
Just use the FOSUserBundle
and create additional routes for your registration/login templates and set them all on the appropriate FOSUser-Controller-Action.
So all register forms to the FOS register-action and all login forms to the fos-register action (you can lookup which actions FOS is using for login/register inside the FOS-routing files)