Answers.Body: <p>Not sure what validation error you're expecting from the template code.</p>
  
  <p>Both <code>firstName</code> and <code>lastName</code> are non-required fields that will basically accept any input.</p>
  
  <p><code>photoUrl</code> could return a validation error if, for example, you tried to upload a <code>.txt</code> file to but you're not calling the <code>errorList()</code> macro on that field.</p>
  
  <p>Not sure if <code>userDescription</code> is required or not, but the <code>errorList()</code> macro isn't being called there, either.</p>
  
  <p>Finally, the variable that Craft returns back to the template when there are validation errors is called <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/controllers/UsersController.php#L1105" rel="nofollow noreferrer"><code>account</code></a>.</p>
  
  <p>So you'd want to do something similar to what the <a href="https://craftcms.com/docs/templating/user-registration-form" rel="nofollow noreferrer">User Registration Form</a> example doc does:</p>
  
  <pre><code> {% if account is defined %}
      {{ errorList(account.getErrors('userDescription')) }}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-15T10:23:38.133Z
Answers.Text: Hi Brad, thanks for your reply. When looking at the documentation for the Registration Form, I saw the `account` variable, but it wasn't clear whether that was a special super-global created during the registration process (because the user doesn't exist yet) or if it was available on the other pages, such as profile, since the Profile Edit example shows no use of it.
  
  I've now edited my code, here: http://pastebin.com/nT5kNqMx
  
  This is now working, so it indeed is the use of the `account` variable - many thanks!
Answers.UserDisplayName: Robert Tolton
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-28T14:49:02.507Z
Answers.Text: Worth noting that in Craft 3, the errors returned to the template are no longer called `account`, but `user`. Would be good to add that to the C3 docs as well, as I had to go digging through the UsersController.php file to figure out why it wasn't working.
Answers.UserDisplayName: James Smith
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-14T19:31:48.927Z
Answers.LastActivityDate: 2017-02-14T19:31:48.927Z
Answers.UserDisplayName: Brad Bell
Body: <p>I've been looking at the following resources:</p>
  
  <p><a href="https://craftcms.com/docs/templating/user-profile-form" rel="nofollow noreferrer">https://craftcms.com/docs/templating/user-profile-form</a></p>
  
  <p><a href="https://craftcms.stackexchange.com/questions/1011/allow-user-to-change-or-delete-their-photo-for-their-profile-from-the-front-end">Allow user to change or delete their photo for their profile from the front end</a></p>
  
  <p><a href="https://craftcms.stackexchange.com/questions/2813/front-end-edit-entry-doesn-t-get-saved">Front end edit: entry doesn’t get saved</a></p>
  
  <p><a href="https://craftcms.stackexchange.com/questions/12200/front-end-registration-form-no-errors">Front end registration form, no errors</a></p>
  
  <p>To try and put together a profile editing page that returns errors once submitted, but can't seem to get it.</p>
  
  <p><code>user</code> is equal to either the <code>currentUser</code> or <code>craft.users.id(craft.request.getSegment(3)).first()</code></p>
  
  <pre><code>&lt;form method="post" accept-charset="UTF-8" enctype="multipart/form-data"&gt;
  
  {{ getCsrfInput() }}
  &lt;input type="hidden" name="action" value="users/saveUser"&gt;
  &lt;input type="hidden" name="redirect" value="partners/view/{{ user.id }}"&gt;
  &lt;input type="hidden" name="userId" value="{{ user.id }}"&gt;
  
  {% macro errorList(errors) %}
      {% if errors %}
          &lt;ul class="errors"&gt;
              {% for error in errors %}
                  &lt;li&gt;{{ error }}&lt;/li&gt;
              {% endfor %}
          &lt;/ul&gt;
      {% endif %}
  {% endmacro %}
  
  {% from _self import errorList %}
  
  {{ dump(user.getErrors) }}
  
  &lt;div class="row"&gt;
      &lt;div class="col-xs-12 col-sm-6"&gt;
          &lt;label for="firstName"&gt;First Name:&lt;/label&gt;
          &lt;input id="firstName" name="firstName" autocomplete="off" type="text" data-parsley-required="true" value="{{ user.firstName }}"&gt;
          {{ errorList(user.getErrors('firstName')) }}
      &lt;/div&gt;
      &lt;div class="col-xs-12 col-sm-6"&gt;
          &lt;label for="lastName"&gt;Last Name:&lt;/label&gt;
          &lt;input id="lastName" name="lastName" autocomplete="off" type="text" data-parsley-required="true" value="{{ user.lastName }}"&gt;
          {{ errorList(user.getErrors('lastName')) }}
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="row"&gt;
      &lt;div class="col-xs-12"&gt;
          &lt;label for="email"&gt;Email:&lt;/label&gt;
          &lt;input id="email" name="email" autocomplete="off" type="email" data-parsley-required="true" data-parsley-type="email" value="{{ user.email }}"&gt;
          {{ errorList(user.getErrors('email')) }}
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="row"&gt;
      &lt;div class="col-xs-12"&gt;
          &lt;label for="userPhoto"&gt;User Photo:&lt;/label&gt;
          {% if user.photoUrl %}
              &lt;img src="{{ user.photoUrl }}" id="userPhoto" width="100" height="100" /&gt;
              &lt;input type="hidden" name="deleteUserPhoto" id="deleteUserPhotoInput" value=""&gt;
          {% else %}
              &lt;img src="{{ currentUserPhotoUrl }}" width="100" height="100"  alt="No User Photo" /&gt;
          {% endif %}
              &lt;input id="profilePhoto" type="file" accept="image/*" capture="camera" name="userPhoto" value="{{ (user.photoUrl ? 'Change Photo' : 'Upload') }}"&gt;
          {% if user.photoUrl %}
              &lt;a id="btn-delete-user-photo" class="btn btn-solid btn-xs"&gt;Delete&lt;/a&gt;
          {% endif %}
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="row"&gt;
      &lt;div class="col-xs-12"&gt;
          &lt;label for="userDescription"&gt;User Description&lt;/label&gt;
          &lt;textarea id="userDescription" name="fields[userDescription]" autocomplete="off" data-parsley-required="true" value="{{ user.userDescription }}"&gt;&lt;/textarea&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;button type="submit" class="btn btn-solid"&gt;Save&lt;/button&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>Could anyone point out where I'm going wrong, or provide a working example?</p>
  
  <p>Many thanks!</p>
  
Tags: <form><frontend><user-profile><usermodel><error-handling>
Title: Correct way of showing errors when editing profile via front-end form?
ThreadText: # Correct way of showing errors when editing profile via front-end form?
  
  (Asked by: username_0 on 2017-02-14)
  
  I've been looking at the following resources:
  
  <https://craftcms.com/docs/templating/user-profile-form>
  
  [Allow user to change or delete their photo for their profile from the front end](https://craftcms.stackexchange.com/questions/1011/allow-user-to-change-or-delete-their-photo-for-their-profile-from-the-front-end)
  
  [Front end edit: entry doesn’t get saved](https://craftcms.stackexchange.com/questions/2813/front-end-edit-entry-doesn-t-get-saved)
  
  [Front end registration form, no errors](https://craftcms.stackexchange.com/questions/12200/front-end-registration-form-no-errors)
  
  To try and put together a profile editing page that returns errors once submitted, but can't seem to get it.
  
  `user` is equal to either the `currentUser` or `craft.users.id(craft.request.getSegment(3)).first()`
  
  ```
  <form method="post" accept-charset="UTF-8" enctype="multipart/form-data">
  
  {{ getCsrfInput() }}
  <input type="hidden" name="action" value="users/saveUser">
  <input type="hidden" name="redirect" value="partners/view/{{ user.id }}">
  <input type="hidden" name="userId" value="{{ user.id }}">
  
  {% macro errorList(errors) %}
      {% if errors %}
          <ul class="errors">
              {% for error in errors %}
                  <li>{{ error }}</li>
              {% endfor %}
          </ul>
      {% endif %}
  {% endmacro %}
  
  {% from _self import errorList %}
  
  {{ dump(user.getErrors) }}
  
  <div class="row">
      <div class="col-xs-12 col-sm-6">
          <label for="firstName">First Name:</label>
          <input id="firstName" name="firstName" autocomplete="off" type="text" data-parsley-required="true" value="{{ user.firstName }}">
          {{ errorList(user.getErrors('firstName')) }}
      </div>
      <div class="col-xs-12 col-sm-6">
          <label for="lastName">Last Name:</label>
          <input id="lastName" name="lastName" autocomplete="off" type="text" data-parsley-required="true" value="{{ user.lastName }}">
          {{ errorList(user.getErrors('lastName')) }}
      </div>
  </div>
  
  <div class="row">
      <div class="col-xs-12">
          <label for="email">Email:</label>
          <input id="email" name="email" autocomplete="off" type="email" data-parsley-required="true" data-parsley-type="email" value="{{ user.email }}">
          {{ errorList(user.getErrors('email')) }}
      </div>
  </div>
  
  <div class="row">
      <div class="col-xs-12">
          <label for="userPhoto">User Photo:</label>
          {% if user.photoUrl %}
              <img src="{{ user.photoUrl }}" id="userPhoto" width="100" height="100" />
              <input type="hidden" name="deleteUserPhoto" id="deleteUserPhotoInput" value="">
          {% else %}
              <img src="{{ currentUserPhotoUrl }}" width="100" height="100"  alt="No User Photo" />
          {% endif %}
              <input id="profilePhoto" type="file" accept="image/*" capture="camera" name="userPhoto" value="{{ (user.photoUrl ? 'Change Photo' : 'Upload') }}">
          {% if user.photoUrl %}
              <a id="btn-delete-user-photo" class="btn btn-solid btn-xs">Delete</a>
          {% endif %}
      </div>
  </div>
  
  <div class="row">
      <div class="col-xs-12">
          <label for="userDescription">User Description</label>
          <textarea id="userDescription" name="fields[userDescription]" autocomplete="off" data-parsley-required="true" value="{{ user.userDescription }}"></textarea>
      </div>
  </div>
  
  <button type="submit" class="btn btn-solid">Save</button>
  
  </form>
  
  ```
  
  Could anyone point out where I'm going wrong, or provide a working example?
  
  Many thanks!
  
  **Tags:** form, frontend, user-profile, usermodel, error-handling
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-02-14. Score: 1 | Accepted answer
  
  Not sure what validation error you're expecting from the template code.
  
  Both `firstName` and `lastName` are non-required fields that will basically accept any input.
  
  `photoUrl` could return a validation error if, for example, you tried to upload a `.txt` file to but you're not calling the `errorList()` macro on that field.
  
  Not sure if `userDescription` is required or not, but the `errorList()` macro isn't being called there, either.
  
  Finally, the variable that Craft returns back to the template when there are validation errors is called [`account`](https://github.com/pixelandtonic/Craft-Release/blob/master/app/controllers/UsersController.php#L1105).
  
  So you'd want to do something similar to what the [User Registration Form](https://craftcms.com/docs/templating/user-registration-form) example doc does:
  
  ```
   {% if account is defined %}
      {{ errorList(account.getErrors('userDescription')) }}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Hi username_1, thanks for your reply. When looking at the documentation for the Registration Form, I saw the `account` variable, but it wasn't clear whether that was a special super-global created during the registration process (because the user doesn't exist yet) or if it was available on the other pages, such as profile, since the Profile Edit example shows no use of it.  I've now edited my code, here: http://pastebin.com/nT5kNqMx  This is now working, so it indeed is the use of the `account` variable - many thanks!  
  > **username_2**: Worth noting that in Craft 3, the errors returned to the template are no longer called `account`, but `user`. Would be good to add that to the C3 docs as well, as I had to go digging through the UsersController.php file to figure out why it wasn't working.  
  
  ---
  
  