<p>Add another hidden input field &quot;entryId&quot; to your form. There's nice <a href="http://buildwithcraft.com/docs/templating/entry-form#editing-entry-form" rel="nofollow noreferrer">example code in the Docs</a>:</p>
<blockquote>
<p>You can modify the form to save existing entries by adding an “entryId” hidden input to the form:</p>
<pre><code>&lt;input type=&quot;hidden&quot; name=&quot;entryId&quot; value=&quot;{{ entry.id }}&quot;&gt;
</code></pre>
</blockquote>

CC BY-SA 3.0
2014-10-27T12:43:25.507Z
Yeah I saw that but I can't make sense of it. Users currently post entries using a form in jobs/new/index.html. The entry is viewed with jobs/{slug}. How would I go about passing the entryId into a form inside jobs/edit/index.html so users can view and edit changes? I'm pretty lost, sorry if this is confusing.
Jamie O'Hanlon
CC BY-SA 3.0
2014-10-27T14:09:20.577Z
There are a number of ways to accomplish this. One way is to just request the same template `jobs/{slug}` but with a post or get variable 'edit', then test for the variable in the template and instead of the normal content, deliver a pre-populated form. Another would be to send the `entry.id` using post or get to the edit form, which would set the hidden field (and populate the fields). If you need an example, let us know.
Douglas McDonald
CC BY-SA 3.0
2014-10-27T15:13:35.037Z
I've got the form working and this is how I've done it. I've got an edit link leading to jobs/edit/{{ entry.id }} and inside my edit template I've included this in the form:
<input type="hidden" name="entryId" value="{{ craft.request.getSegment(3) }}">

This is working and I can edit and save an entry, however prepopulating the form with {%- if entry is defined %} value="{{ entry.title }}"{% endif -%} doesn't work at all. Any idea why?
Jamie O'Hanlon
CC BY-SA 3.0
2014-10-27T15:25:07.387Z
@Jamie because the template is not set in the section settings, you don't get a var `entry` pre-populated. So you have to set it yourself: `{% set entry = craft.entries.id(craft.request.getSegment(3)).first() %}` or better, set a var `id` first: `{% set id = craft.request.getSegment(3) %}` and then get the entry model with `{% set entry = craft.entries.id(id).first() %}`.
carlcs
CC BY-SA 3.0
2014-10-27T12:21:31.130Z
2014-10-27T12:21:31.130Z
2020-06-17T08:56:27.903Z
carlcs
<p>Users can currently submit entries using a form on the front-end. How would I go about showing the current logged in user's existing entries and allow them to edit them through another front-end form? </p>

<entries><form><frontend>
How do I enable editing of entries with a front-end form?
# How do I enable editing of entries with a front-end form?

(Asked by: username_0 on 2014-10-27)

Users can currently submit entries using a form on the front-end. How would I go about showing the current logged in user's existing entries and allow them to edit them through another front-end form?

**Tags:** entries, form, frontend

---

## 1 answers

### Answer by username_1 on 2014-10-27. Score: 4

Add another hidden input field "entryId" to your form. There's nice example code in the Docs:

You can modify the form to save existing entries by adding an “entryId” hidden input to the form:

> **Comments:**
> **username_0**: Yeah I saw that but I can't make sense of it. Users currently post entries using a form in jobs/new/index.html. The entry is viewed with jobs/{slug}. How would I go about passing the entryId into a form inside jobs/edit/index.html so users can view and edit changes? I'm pretty lost, sorry if this is confusing.  
> **username_2**: There are a number of ways to accomplish this. One way is to just request the same template `jobs/{slug}` but with a post or get variable 'edit', then test for the variable in the template and instead of the normal content, deliver a pre-populated form. Another would be to send the `entry.id` using post or get to the edit form, which would set the hidden field (and populate the fields). If you need an example, let us know.  
> **username_0**: I've got the form working and this is how I've done it. I've got an edit link leading to jobs/edit/{{ entry.id }} and inside my edit template I've included this in the form: <input type="hidden" name="entryId" value="{{ craft.request.getSegment(3) }}">  This is working and I can edit and save an entry, however prepopulating the form with {%- if entry is defined %} value="{{ entry.title }}"{% endif -%} doesn't work at all. Any idea why?  
> **username_1**: @Jamie because the template is not set in the section settings, you don't get a var `entry` pre-populated. So you have to set it yourself: `{% set entry = craft.entries.id(craft.request.getSegment(3)).first() %}` or better, set a var `id` first: `{% set id = craft.request.getSegment(3) %}` and then get the entry model with `{% set entry = craft.entries.id(id).first() %}`.  

---

