FOSUserBundle更改寄存器表单字段名称

FOSUserBundle更改寄存器表单字段名称

问题描述:

I am developing an app using Symfony 2 and using FOSUserBundle. I would like to know if it is possible to define my own form with my own custom field names. I know the Symfony 2 Security Component allows you to map the field names for the login route but I don't know of a way to do so with the register form. I want to have fields like name, email instead of fos_user_registration_form[email] etc. Do I need to write a custom controller to handle the user registration or is there a configuration section in the firewall I can modify?

我正在使用Symfony 2和使用FOSUserBundle开发应用程序。 我想知道是否可以使用我自己的自定义字段名称定义自己的表单。 我知道Symfony 2安全组件允许您映射登录路由的字段名称,但我不知道使用注册表单的方法。 我希望有 name code>, email code>等字段,而不是 fos_user_registration_form [email] code>等。我是否需要编写自定义控制器来处理用户 注册或我可以修改防火墙中的配置部分吗? p> div>

In the FOSUserBundle configuration, set fos_user.registration.form.name value to null or empty string (FOSUserBundle configuration reference).

Also see this question: Symfony2 Form Component - creating fields without the forms name in the name attribute