Search code examples
phpformssymfonyfosuserbundlecdn

Override registration form in FOSUserBundle Symfony


I am trying to override the default areas of the fosuserbundle registration form. I added all the required fields I wanted through database and customize with the bootstrap cdn. But when I try to customize the defaults fields of the registration form, I cannot find it in both register_content.html.twig and register.html.twig to edit them.

register_content.html.twig

{% trans_default_domain 'FOSUserBundle' %}

{{ form_start(form, {'method': 'post', 'action': path('fos_user_registration_register'), 'attr': {'class': 'fos_user_registration_register'}}) }}
    {{ form_widget(form) }}
    <div>

        <input class="btn btn-success" type="submit" id="_submit" name="_submit" value="{{ 'registration.submit'|trans }}" />
    </div>
{{ form_end(form) }}

register.html.twig

{% extends "@FOSUser/layout.html.twig" %}

{% block fos_user_content %}
{% include "@FOSUser/Registration/register_content.html.twig" %}
{% endblock fos_user_content %}

I would like to customize all the following textareas.

  • Email
  • Username
  • Password
  • Repeat password

Where can I find the above fields?

Thanks in advance.


Solution

  • If you want to override existing FormType then follow that doc: http://symfony.com/doc/master/bundles/FOSUserBundle/overriding_forms.html

    If you want to choose specific fields in html, you can select fields like that:

    {{ form_widget(form.email) }}

    {{ form_widget(form.username) }}

    or

    {{ form_widget(form.email, { 'attr': {'class': 'foo'} }) }}