为什么我的错误不出现在Symfony2表单上?

时间:2011-10-04 06:27:51

标签: symfony

我有以下更改密码表单,它覆盖了FOSUserBundle的表单。如果我输入了不匹配的密码/重复密码,表单会再次显示,不会出现任何错误,也不会重定向

<div id="change_password_wrapper">
  <h2>Change your password</h2>
  <form action="{{ path('fos_user_change_password') }}" {{ form_enctype(form) }} method="POST" class="fos_user_change_password">
    {%if form_errors(form)%}
    <div class="ui-state-error ui-corner-all">
      <p>
        <span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
<strong>Error:</strong>
      {{ form_errors(form) }}
        </p>
    </div>
    {% endif %}
        <div class="form-row">
          {{ form_label(form.current, 'Current password: ') }}
          {{ form_errors(form.current) }}
          {{ form_widget(form.current) }}
        </div>
        <div class="form-row">
          {{ form_label(form.new.first, 'New password: ') }}
          {{ form_errors(form.new.first) }}
          {{ form_widget(form.new.first) }}
        </div>
        <div class="form-row">
          {{ form_label(form.new.second, 'Verify password: ') }}
          {{ form_errors(form.new.second) }}
          {{ form_widget(form.new.second) }}
        </div>
      <div class="form_row">
          <input type="submit" value="{{ 'change_password.submit'|trans({}, 'FOSUserBundle') }}" />
      </div>
    {{ form_rest(form) }}
  </form>
</div>

1 个答案:

答案 0 :(得分:0)

您还应将其添加到表单中:

{{ form_errors(form.new) }}

现在你应该有一条错误信息