Answers.Body: <p>I've updated our front-end entry template example to show you how this can be done:</p>
  
  <p><a href="http://buildwithcraft.com/docs/templating/entry-form" rel="nofollow">http://buildwithcraft.com/docs/templating/entry-form</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-11T18:14:30.883Z
Answers.LastActivityDate: 2014-08-11T18:14:30.883Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>If there are any problems with your submission, Craft sets an <code>entry</code> route variable<sup>1</sup>, which you can use to retrieve the previously-posted form data.</p>
  
  <p>Here's an example of how you might do that:</p>
  
  <pre><code>&lt;input
      id="title"
      type="text"
      name="title"
      value="{{ entry is defined ? entry.title : '' }}",
  &gt;
  </code></pre>
  
  <p>You can also retrieve the errors from the <code>entry</code> variable:</p>
  
  <pre><code>{% if (entry is defined) and (entry.hasErrors('title')) %}
      &lt;span class="error"&gt;{{ entry.getError('title') }}&lt;/span&gt;
  {% endif %}
  </code></pre>
  
  <p>If you want to learn more about the validation-related methods available on the <code>entry</code> object (such as the difference between <code>getError</code> and <code>getErrors</code>), I've <a href="https://experiencehq.net/blog/the-definitive-guide-to-validation-in-craft-part-1-foundations" rel="nofollow">written a blog post</a> on the subject.</p>
  
  <p>Stephen</p>
  
  <ol>
  <li>Take a look at line 477 of <code>craft/app/controllers/EntriesController.php</code></li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-11T18:10:36.003Z
Answers.LastActivityDate: 2014-08-11T18:10:36.003Z
Answers.UserDisplayName: Stephen Lewis
Body: <p>I am looking for some help with persistent form data. </p>
  
  <p>If a user submits a front-end entry form for some Entries data, but there are errors with the submission, they are currently redirected to the entry page and successfully shown the errors (eg field is required). Is there a method or syntax where this form can also retrieve the posted form data so the user is not required to fill in the whole form again?</p>
  
  <p>Many thanks for any help from the community!</p>
  
  <p>Dan</p>
  
Tags: <form>
Title: Persistent Form Data
ThreadText: # Persistent Form Data
  
  (Asked by: username_0 on 2014-08-11)
  
  I am looking for some help with persistent form data.
  
  If a user submits a front-end entry form for some Entries data, but there are errors with the submission, they are currently redirected to the entry page and successfully shown the errors (eg field is required). Is there a method or syntax where this form can also retrieve the posted form data so the user is not required to fill in the whole form again?
  
  Many thanks for any help from the community!
  
  Dan
  
  **Tags:** form
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-08-11. Score: 2 | Accepted answer
  
  I've updated our front-end entry template example to show you how this can be done:
  
  <http://buildwithcraft.com/docs/templating/entry-form>
  
  
  ---
  
  ### Answer by username_2 on 2014-08-11. Score: 2
  
  If there are any problems with your submission, Craft sets an `entry` route variable1, which you can use to retrieve the previously-posted form data.
  
  Here's an example of how you might do that:
  
  ```
  <input
      id="title"
      type="text"
      name="title"
      value="{{ entry is defined ? entry.title : '' }}",
  >
  
  ```
  
  You can also retrieve the errors from the `entry` variable:
  
  ```
  {% if (entry is defined) and (entry.hasErrors('title')) %}
      <span class="error">{{ entry.getError('title') }}</span>
  {% endif %}
  
  ```
  
  If you want to learn more about the validation-related methods available on the `entry` object (such as the difference between `getError` and `getErrors`), I've [written a blog post](https://experiencehq.net/blog/the-definitive-guide-to-validation-in-craft-part-1-foundations) on the subject.
  
  username_2
  
  1. Take a look at line 477 of `craft/app/controllers/EntriesController.php`
  
  
  ---
  
  