从模板点击此按钮时
:<form action="{{ path('fos_user_registration_register') }}" method="post">
<button class="btn btn-small btn-success" type="submit">S'inscrire</button>
</form>
然后我访问我的UserBundle/Resources/view/Registration/register/html.twig
(然后覆盖FOSUSerBundle默认表单):
{% extends "FOSUserBundle::layout.html.twig" %}
{% block fos_user_content %}
<form action="{{ path('fos_user_registration_register') }}" {{ form_enctype(form) }} method="POST" class="fos_user_registration_register">
{{ form_rest(form) }}
<div>
<input type="submit" value="{{ 'registration.submit'|trans({}, 'FOSUserBundle') }}" />
</div>
</form>
{% endblock fos_user_content %}
由于某些原因,所有验证消息都会出现(例如请输入用户名),虽然我没有提交表格的事件!?
对此有何解释?
如何自定义FOSUser模板并重定向error_message,不显示或更改消息或显示?
答案 0 :(得分:1)
最后我覆盖了registration_content视图:
<form action="/projet_etienne_auth/web/app_dev.php/register/" method="POST" class="fos_user_registration_register">
{{ form_errors(form) }}
{{ form_widget(form._token) }}
<div>
<label for="fos_user_registration_form_username" class="required">Nom d'utilisateur :</label>
<input type="text" id="fos_user_registration_form_username" name="fos_user_registration_form[username]" required="required" maxlength="255" pattern=".{2,}" /></div>
<div>
<label for="fos_user_registration_form_email" class="required">Adresse e-mail :</label>
<input type="email" id="fos_user_registration_form_email" name="fos_user_registration_form[email]" required="required" /></div>
<div>
<label for="fos_user_registration_form_plainPassword_first" class="required">Mot de passe :</label>
<input type="password" id="fos_user_registration_form_plainPassword_first" name="fos_user_registration_form[plainPassword][first]" required="required" />
</div>
<div><label for="fos_user_registration_form_plainPassword_second" class="required">Vérification :</label>
<input type="password" id="fos_user_registration_form_plainPassword_second" name="fos_user_registration_form[plainPassword][second]" required="required" />
</div><div>
<input type="submit" value="Enregistrer" />