0

我正在尝试覆盖我的 html 树枝视图,希望它能解决验证消息的问题。

html 树枝文件:

    {% 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">



 <div>
     <label for="fos_user_registration_form_username" class="required">Nom d&#039;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="{{ 'registration.submit'|trans({}, 'FOSUserBundle') }}"    />
</div>
  </form>
 {% endblock fos_user_content %}

表单显示正确但未提交。

根据 FOSUser 捆绑实体,输入名称是否正确?缺少什么,出了什么问题?如何显示错误?如何处理 CSRF 隐藏域?

4

1 回答 1

1

我这样解决了我的问题:

 <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&#039;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" />
</div>

{{ form_widget(form) }} 或 {{ form_rest(form) }} 正在生成不适当的验证消息或 csrf_error。

希望它可以帮助某人...

于 2012-12-18T15:08:24.280 回答