0

我想为我的用户提供不同的登录/注册页面/表单,但用户是同一类。我不想用其他表填充数据库。

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]

这是注册类:

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');
    }

不幸的是,这些表格最终都成为了最后一种用户类型,即 pacients。此配置不起作用主要是因为UserDiscriminator按类而不是用户类型名称获取值。

是否有任何类型的配置可以帮助或是否有人知道我如何实现这一目标?

4

1 回答 1

0

不要PuGXMultiUserBundle为您的需要使用它没有意义。

只需使用FOSUserBundle并为您的注册/登录模板创建附加路由,并将它们全部设置在适当的 FOSUser-Controller-Action 上。

因此,FOS 注册操作的所有注册表单和 fos-register 操作的所有登录表单(您可以在 FOS 路由文件中查找 FOS 用于登录/注册的操作)

于 2016-04-29T17:16:20.670 回答