how to overriding fosuserbundle registration form style

房东的猫 提交于 2019-12-06 11:52:17

Give it a try with:

https://symfony.com/doc/master/bundles/FOSUserBundle/overriding_forms.html FOS User bundled moved the documentations to symfony.com docs.

edit: updated link

You can render each part of the form instead of form_widget(form)

like

{% form_theme form with '@user/form/fields.html' %}

{{ form_errors(form) }}

{{ form_label(form.username) }}
{{ form_widget(form.username) }}
{{ form_errors(form.username) }}

{{ form_label(form.email) }}
{{ form_widget(form.email) }}
{{ form_errors(form.email) }}

{{ form_label(form.plainPassword.first) }}
{{ form_widget(form.plainPassword.first) }}
{{ form_errors(form.plainPassword.first) }}

{{ form_label(form.plainPassword.second) }}
{{ form_widget(form.plainPassword.second) }}

{{ form_rest(form) }}

More info is here:

https://github.com/FriendsOfSymfony/FOSUserBundle/issues/1077

you can do :

<form action="{{ path('fos_user_registration_register') }}" {{ form_enctype(form) }} method="POST">
<div class="form-group" id="fos_user_registration_form">
    {{ form_widget(form.email, { 'attr': {'class': 'form-control', 'placeholder': 'form.email'|trans } }) }}
    {{ form_errors(form.email) }}

    {{ form_widget(form.username, { 'attr': {'class': 'form-control', 'placeholder': 'form.username'|trans } }) }}
    {{ form_errors(form.username) }}

    {{ form_widget(form.plainPassword.first, { 'attr': {'class': 'form-control', 'placeholder': 'form.password'|trans } }) }}
    {{ form_errors(form.plainPassword.first) }}

    {{ form_widget(form.plainPassword.second, { 'attr': {'class': 'form-control', 'placeholder': 'form.password_confirmation'|trans } }) }}
    {{ form_errors(form.plainPassword.second) }}

    {{ form_rest(form) }}

</div>
<div>
    <input class="btn btn-lg btn-primary btn-block" type="submit" value="{{ 'registration.submit'|trans }}">
</div>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!