<p>The <code>saveEntry</code> controller used by the default example returns an <code>entry</code> variable with the newly created item and the applicable error messages. This could be a potential cause of conflict if you have another variable called <code>entry</code>, which is by default pre-loaded in entry templates. </p>

<p>I think you could create a (for example) <code>product.twig</code> template and manually set an entry variable (via ID or slug) called anything else than <code>entry</code>.</p>

CC BY-SA 3.0
2017-07-06T09:16:36.123Z
Hmm, I see what you are suggesting. Thanks. A bit of a PITA though as that will cause issues with template fragments that need the "create entry" entry - things like SEOmatic.

Shame we can't define the variable name that the saveEntry controller spits back :/
Matt Wilcox
CC BY-SA 3.0
2017-07-06T11:57:06.423Z
Well as a workaround you can save the form with an ajax request. In this case, the controller will return a JSON object that you will need to handle via js... not sure if this will translate less work :)
gioppe
CC BY-SA 3.0
2017-07-06T08:38:26.383Z
2017-07-06T08:38:26.383Z
gioppe
<p>The official example ( <a href="https://craftcms.com/docs/templating/entry-form" rel="nofollow noreferrer">https://craftcms.com/docs/templating/entry-form</a> ) seems to assume that the form itself is not already on a page which is an Entry. Dropping this form into a template that has an entry loaded already spits out that entry's entry.title or entry.body.</p>

<p>How should this work? We want the "new entry form" to live on a page that the client controls the content for.</p>

<form>
Front end Entry form with validation error support?
# Front end Entry form with validation error support?

(Asked by: username_0 on 2017-07-06)

The official example ( <https://craftcms.com/docs/templating/entry-form> ) seems to assume that the form itself is not already on a page which is an Entry. Dropping this form into a template that has an entry loaded already spits out that entry's entry.title or entry.body.

How should this work? We want the "new entry form" to live on a page that the client controls the content for.

**Tags:** form

---

## 1 answers

### Answer by username_1 on 2017-07-06. Score: 1

The `saveEntry` controller used by the default example returns an `entry` variable with the newly created item and the applicable error messages. This could be a potential cause of conflict if you have another variable called `entry`, which is by default pre-loaded in entry templates.

I think you could create a (for example) `product.twig` template and manually set an entry variable (via ID or slug) called anything else than `entry`.

> **Comments:**
> **username_0**: Hmm, I see what you are suggesting. Thanks. A bit of a PITA though as that will cause issues with template fragments that need the "create entry" entry - things like SEOmatic.  Shame we can't define the variable name that the saveEntry controller spits back :/  
> **username_1**: Well as a workaround you can save the form with an ajax request. In this case, the controller will return a JSON object that you will need to handle via js... not sure if this will translate less work :)  

---

