3

I've got a form to change a user password.
When the passwords aren't the same, the error message is displayed twice.

This is my code :

<div class="input-icon">
   <i class="fa fa-lock"></i>
   {{ form_widget(form.currentPassword, {'attr':{'type': 'text', 'class': 'form-control placeholder-no-fix', 'autocomplete': 'off', 'placeholder': 'sylius.form.user_change_password.current'|trans, 'name': 'current'}} ) }}
   {{ form_errors(form.currentPassword) }}
</div>

And this is the result

enter image description here

The theme :

{%- block form_errors -%}
    {%- if errors|length > 0 -%}
        {%- for error in errors -%}
            <div class="ui red {% if form.parent is not empty %}pointing {% endif %}label sylius-validation-error"{% if form.parent is empty %} style="margin-bottom: 10px;"{% endif %}>
                {{ error.message }}
            </div>
        {%- endfor -%}
    {%- endif -%}
{%- endblock form_errors -%}
N.Jourdan
  • 590
  • 2
  • 4
  • 22
  • 2
    did you try without `{{ form_errors(form.currentPassword) }}`? – Arcv Jun 09 '17 at 07:45
  • can you please put your model update code also here or jsfiddle if possible would be better – manish1706 Jun 09 '17 at 07:57
  • 2
    Maybe `form_widget` give the result if it works and return the error message. So `form_widget` return the error msg and you return the error message with `form_errors` – Sylvain Attoumani Jun 09 '17 at 08:50
  • If I remove {{ form_errors(form.currentPassword) }}, there is no more errors displayed – N.Jourdan Jun 09 '17 at 08:53
  • probably you have two validation errors, if so check the validation assertion in your model or in the form definition class – Matteo Jun 09 '17 at 09:32

0 Answers0