<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>

CC BY-SA 3.0
2014-08-11T18:14:30.883Z
2014-08-11T18:14:30.883Z
Brad Bell
<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>

CC BY-SA 3.0
2014-08-11T18:10:36.003Z
2014-08-11T18:10:36.003Z
Stephen Lewis
<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>

<form>
Persistent Form Data
# 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:


You can also retrieve the errors from the entry variable:
{% if (entry is defined) and (entry.hasErrors('title')) %}
    {{ entry.getError('title') }}
{% 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 on the subject.
Stephen

Take a look at line 477 of craft/app/controllers/EntriesController.php


---

