<p>If you use the <a href="https://github.com/pixelandtonic/GuestEntries" rel="nofollow">Guest Entries</a> plugin to submit the entry, then the variable that the invalid entry is called is actually configurable, using the <a href="https://github.com/pixelandtonic/GuestEntries#configuration" rel="nofollow">entryVariable</a> config setting.</p>

<p>So just create a new file in craft/config/ called guestentries.php, with this:</p>

<pre><code>&lt;?php

return array(
    'entryVariable' =&gt; 'invalidEntry'
);
</code></pre>

<p>Then from your template you can just check to see if <code>invalidEntry</code> is defined.</p>

CC BY-SA 3.0
2014-11-02T18:36:42.807Z
Hi brandon, what if not using guest entry but normal form? How do i change the variable like the same as guest entry? Cause my single page using "entry" and form too using "entry" as well.
Hs Tung
CC BY-SA 3.0
2014-11-02T23:06:50.527Z
@HsTung Currently it’s not possible with the normal entries/saveEntry action.
Brandon Kelly
CC BY-SA 3.0
2014-11-02T16:38:01.277Z
2014-11-02T16:38:01.277Z
Brandon Kelly
<p>It sounds like you've got your home page setup as a Single. Which is a great way to go, and that's what is <strong>automatically setting the <code>entry</code> variable</strong>.</p>

<p>Here's a great walkthrough on creating an "edit entry" form...</p>

<blockquote>
  <p><a href="http://buildwithcraft.com/docs/templating/entry-form" rel="nofollow">http://buildwithcraft.com/docs/templating/entry-form</a></p>
</blockquote>

<p>Keep in mind, that example uses <code>entry</code> to represent the entry being edited. That won't work for you, however, since <code>entry</code> is being automatically set as your home page Single.</p>

<p>So when you're attempting to modify another entry, I'd recommend setting it to a <em>different</em> variable name. Obviously you can't have your home page and other entry both be represented by a variable named <code>entry</code>.</p>

<pre><code>{% set entryToEdit = craft.entries.slug('my-entry-to-edit').first %}
</code></pre>

<p>Then <code>entryToEdit</code> would replace any instances of <code>entry</code> in the <a href="http://buildwithcraft.com/docs/templating/entry-form" rel="nofollow">documented example</a>.</p>

CC BY-SA 3.0
2014-11-01T15:54:55.217Z
Thanks for your answer but what if that is new entry form but not edit form?
I want to retain the value when there is error occur after form post. the form exactly like mention in doc
`http://buildwithcraft.com/docs/templating/entry-form`
How should I replace the entry variable in the form with something else since you mention single had use my entry variable.
Hs Tung
CC BY-SA 3.0
2014-11-01T18:26:52.100Z
That's an interesting question... Typically, when you submit to `entries/saveEntry` (as this form is doing) it will reload the page with any error messages attached to the `entry` object. Those would be accessed via `entry.getErrors()`. But... what would it return in this case? Would there be a collision when the page is reloaded? I suspect there would be... You may want to email support@buildwithcraft.com to get more clarification.
Lindsey D
CC BY-SA 3.0
2014-11-01T15:27:57.263Z
2014-11-01T15:27:57.263Z
Lindsey D
<p>I got this plugin from Brandon.
<a href="https://github.com/pixelandtonic/GuestEntries" rel="nofollow">https://github.com/pixelandtonic/GuestEntries</a></p>

<p>And it solve the problem I face.
Now I able allow guest to submit entry and it able to change the variable not to use entry but any variable you name in config.</p>

CC BY-SA 3.0
2014-11-02T16:33:39.640Z
2014-11-02T16:33:39.640Z
Hs Tung
<p>I have an entry form in home page which the home page already using the entry object.</p>

<p>And I am placing the entry form in home page when i call</p>

<blockquote>
  <p>{%- if entry is defined %} value="{{ entry.title }}"{% endif -%}</p>
</blockquote>

<p>and this will grab the home page title, and this is not the result i want.
I need when the form submit and error return with value.</p>

<p>By the way, any source to learn about entry form? I don't see much tutorial about entry form. Thanks.</p>

CC BY-SA 3.0
2015-02-03T20:14:33.663Z
What does the hyphen mean in the tag? This part: "{%-". As in, what's the difference between {% if %} and {%- if %}
Nathan D Huening
CC BY-SA 3.0
2015-02-04T09:19:19.447Z
@NathanDHuening Using hyphens in your Twig tags allows you to remove whitespace. Have a look here: http://twig.sensiolabs.org/doc/templates.html#whitespace-control
Jamie Wade
CC BY-SA 3.0
2015-02-04T10:03:06.420Z
@JamieWade Ah.. Thanks for the explaination. Me myself also forgot this. haha
Hs Tung
<form>
Entry form in home page
# Entry form in home page

(Asked by: username_0 on 2014-11-01)

I have an entry form in home page which the home page already using the entry object.

And I am placing the entry form in home page when i call

> {%- if entry is defined %} value="{{ entry.title }}"{% endif -%}

and this will grab the home page title, and this is not the result i want.
I need when the form submit and error return with value.

By the way, any source to learn about entry form? I don't see much tutorial about entry form. Thanks.

**Tags:** form
> **Comments:**
> **username_1**: What does the hyphen mean in the tag? This part: "{%-". As in, what's the difference between {% if %} and {%- if %}  
> **username_2**: @NathanDHuening Using hyphens in your Twig tags allows you to remove whitespace. Have a look here: http://twig.sensiolabs.org/doc/templates.html#whitespace-control  
> **username_0**: @JamieWade Ah.. Thanks for the explaination. Me myself also forgot this. haha  

---

## 3 answers

### Answer by username_3 on 2014-11-02. Score: 3 | Accepted answer

If you use the Guest Entries plugin to submit the entry, then the variable that the invalid entry is called is actually configurable, using the entryVariable config setting.
So just create a new file in craft/config/ called guestentries.php, with this:
 'invalidEntry'
);

Then from your template you can just check to see if invalidEntry is defined.

> **Comments:**
> **username_0**: Hi brandon, what if not using guest entry but normal form? How do i change the variable like the same as guest entry? Cause my single page using "entry" and form too using "entry" as well.  
> **username_3**: @HsTung Currently it’s not possible with the normal entries/saveEntry action.  

---

### Answer by username_4 on 2014-11-01. Score: 3

It sounds like you've got your home page setup as a Single. Which is a great way to go, and that's what is automatically setting the entry variable.
Here's a great walkthrough on creating an "edit entry" form...

http://buildwithcraft.com/docs/templating/entry-form

Keep in mind, that example uses entry to represent the entry being edited. That won't work for you, however, since entry is being automatically set as your home page Single.
So when you're attempting to modify another entry, I'd recommend setting it to a different variable name. Obviously you can't have your home page and other entry both be represented by a variable named entry.
{% set entryToEdit = craft.entries.slug('my-entry-to-edit').first %}

Then entryToEdit would replace any instances of entry in the documented example.

> **Comments:**
> **username_0**: Thanks for your answer but what if that is new entry form but not edit form? I want to retain the value when there is error occur after form post. the form exactly like mention in doc `http://buildwithcraft.com/docs/templating/entry-form` How should I replace the entry variable in the form with something else since you mention single had use my entry variable.  
> **username_4**: That's an interesting question... Typically, when you submit to `entries/saveEntry` (as this form is doing) it will reload the page with any error messages attached to the `entry` object. Those would be accessed via `entry.getErrors()`. But... what would it return in this case? Would there be a collision when the page is reloaded? I suspect there would be... You may want to email support@buildwithcraft.com to get more clarification.  

---

### Answer by username_0 on 2014-11-02. Score: 1

I got this plugin from Brandon.
<https://github.com/pixelandtonic/GuestEntries>

And it solve the problem I face.
Now I able allow guest to submit entry and it able to change the variable not to use entry but any variable you name in config.


---

