I have a user profile form on the frontend that doesn't display errors for a URL field. The field handle is 'website'.

This is my code:

{% macro errorList(errors) %}
{% if errors %}
    {{ ul(errors, {class: 'errors'}) }}
  {% endif %}
{% endmacro %}
{% set user = user ?? currentUser %}

<form method="post" accept-charset="UTF-8" enctype="multipart/form-data">
  {{ csrfInput() }}
  {{ actionInput('users/save-user') }}
  {{ hiddenInput('userId', user.id) }}
  {{ redirectInput("members/my-profile") }}    
  {% if user.hasErrors() %}
    <p><b class="error">The profile could not be saved</b></p>
  {% endif %}
  <input type="text" id="first-name" class="" name="fields[firstNameEnglish]" value="{{ user.firstNameEnglish }}" placeholder="First Name" autocomplete="given-name">   
  <input type="text" id="last-name" class="" name="fields[lastNameEnglish]" value="{{ user.lastNameEnglish }}" placeholder="Last Name" autocomplete="family-name">
  {% if user.hasErrors('website') %}<p><b class="error">Invalid URL</b></p>{% endif %}
  <input type="text" id="website" class="{{ user.hasErrors('website') ? 'error'}}" name="fields[website]" value="{{ user.website }}">
  <button type="submit">Save Profile</button>
  <a href="/en/members/my-profile">Cancel</a>

When I save the form with an invalid URL, the page reloads, all the other field are empty again and there is not error message. What am I doing wrong?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.