<p>I think the way you are trying to add entries requires authentication, if you look on the <a href="http://buildwithcraft.com/docs/templating/entry-form" rel="nofollow">entry form page</a> in the craft docs, you will see this snippet of text:</p>

<blockquote>
  <p>The user submitting the entry will also need to have the permission necessary to create entries for the section they are posting to</p>
</blockquote>

<p>So I think you would need to use the guest entries plugin (from P&amp;T), unless i'm mistaken, so maybe give that a try and see if it fixes the issue?</p>

<p><a href="https://github.com/pixelandtonic/GuestEntries" rel="nofollow">Guest Entries plugin on Github</a></p>

<p>The difference in markup is here:</p>

<pre><code>&lt;input type="hidden" name="action" value="guestEntries/saveEntry"&gt;
</code></pre>

<p>This is the way I have done this on a site i've built and not had any issues, entries get saved and to the specified type. :)</p>

CC BY-SA 3.0
2014-10-28T17:49:08.783Z
Thanks Alec - I've installed GuestEntries (updated question) but it's not solved the problem. When I submit the form, I get taken to the Template Error page in the question (http://i.imgur.com/aYj2a3d.png). It's something to do with the way I'm redirecting structure templates...
darylknight
CC BY-SA 3.0
2014-10-28T17:57:00.687Z
Alec - I'm guess the sites you've done in the past have used a different template routing structure. The error here isn't being caused by permissions, it's because the form is looking for a template that doesn't exist. No idea why it's looking for a template in the first place!
darylknight
CC BY-SA 3.0
2014-10-28T18:03:46.110Z
Added a new answer as it's completely unrelated to the guest entries answer :)
Alec Ritson
CC BY-SA 3.0
2014-10-22T15:38:35.990Z
2014-10-22T15:38:35.990Z
Alec Ritson
<p>Based on the comments from my other answer and seeing the image you sent.</p>

<p>Look in the template <code>hire-us/index.html</code> where you are trying to include a template dynamically with the <code>entry.type</code> variable, what that is generating does not correspond to a template you have, so it can't find the template to include and therefore you are getting the error.
As the error States craft is unable to find the template</p>

<p>Try removing the include altogether and just put <code>{{ entry.type }}</code> in the template and go through the process again so you can see what's being generated and get the name of the template you need to create to satisfy the include.</p>

<p>Hope that helps </p>

CC BY-SA 3.0
2014-10-28T18:26:48.233Z
Hi Alec, thank you for all your help, but it turns out it was simpler than expected. Answered my own question, it was because the Title field was missing ><
darylknight
CC BY-SA 3.0
2014-10-28T19:00:11.787Z
Ahh no worries, glad you got things sorted in the end! :)
Alec Ritson
CC BY-SA 3.0
2014-10-28T18:03:14.497Z
2014-10-28T18:03:14.497Z
Alec Ritson
<p>This has been solved via a support ticket, which I'm posting here for others etc.</p>

<blockquote>
  <p>The first time you load the template, the URI is mapping to your "Get
  A Quote" entry, which gets assigned to the entry variable when your
  template is loaded.</p>
  
  <p>When you submit the form, the same URL is requested again, once again
  matching your "Get A Quote" entry, but this time the
  guestEntries/saveEntry controller action is summoned. When there's a
  validation error, Guest Entries will pass the new entry back to the
  template as an entry variable, overriding the "Get A Quote" entry that
  the URL matched. So, then the template gets routed to
  hire-us/index.html like it normally did, but this time entry.type is
  enquiryWeddingDance instead of getAQuote, since it's a different entry
  altogether. The template tries to include
  hire-us/enquiryWeddingDance.html, but that doesn't exist, so you get
  the error.</p>
  
  <p>To fix this, I've just released an update to the Guest Entries plugin,
  which adds a new <a href="https://github.com/pixelandtonic/GuestEntries#configuration" rel="nofollow">entryVariable config setting</a>. You can use that to
  customize the variable name that Guest Entries will set the invalid
  entry to (i.e. 'guestEntry' or 'invalidEntry'), so it doesn't conflict
  with the entry variable that the request is getting routed to.</p>
</blockquote>

<p>After setting the Guest Entries variable as suggested in the <a href="https://github.com/pixelandtonic/GuestEntries#configuration" rel="nofollow">documentation</a>, it's now working as expected without conflicts. Thanks Brandon!</p>

<p>Usage:</p>

<pre><code>{% if guestEntry is defined %}{{ errorList(guestEntry.getErrors('variableName')) }}{% endif %}
</code></pre>

CC BY-SA 3.0
2014-10-28T18:25:27.917Z
2014-10-30T16:31:07.620Z
2014-10-30T16:31:07.620Z
darylknight
<p>I have a few different forms on my site for different kinds of enquiries, each represented by an <code>Entry Type</code> with different fields in a single <code>Enquiries</code> channel. How can I get the entries/saveEntry form to save as a specific entry type?</p>

<p>My existing form:</p>

<pre><code>&lt;input type="hidden" name="action" value="guestEntries/saveEntry"&gt;
&lt;input type="hidden" name="redirect" value="/hire-us/get-a-quote/success"&gt;
&lt;input type="hidden" name="sectionId" value="61"&gt;
</code></pre>

<p>I have two entry types in that channel, ID 111 and 112. When I add the line:</p>

<pre><code>&lt;input type="hidden" name="typeId" value="111"&gt;
</code></pre>

<p>then submit the form, I get an error message saying "<em>Unable to find the template 'hire-us/enquiryPlanningEvent'</em>". It appears that Craft is looking for a template named after the entry type I'm trying to save, but obviously there isn't one.
What's the solution to this?</p>

CC BY-SA 3.0
2014-10-22T18:26:47.183Z
If you enable [Dev Mode](http://buildwithcraft.com/help/dev-mode) Craft will give you a full stack trace when that error occurs. That may give you more insight into why it’s happening.
Brandon Kelly
CC BY-SA 3.0
2014-10-28T17:46:11.053Z
No stack trace I'm afraid Brandon - I'm seeing this error: http://i.imgur.com/aYj2a3d.png
darylknight
CC BY-SA 3.0
2014-10-28T21:45:24.027Z
Do you have any idea how that template is getting invoked? Maybe via the `redirect` param?
Brandon Kelly
CC BY-SA 3.0
2014-10-30T10:40:29.327Z
I did solve this - but I don't know why the error I got was happening. Basically if the `Title` field is expecting a value (i.e. not set automatically), and I submit the form without setting a title, then it redirects me to a template with the same handle as the Entry Type I was trying to submit to (regardless of the `redirect` value). Bug?
darylknight
CC BY-SA 3.0
2014-10-30T10:53:54.110Z
Actually it's not just if the Title field is missing, it happens if any required field has no data. Filing a bug report. Expected behaviour is that it should reload the page and call the errorList.
darylknight
<entries><form><entry-type><guest-entries>
How do I save a front-end form as a specific Entry Type?
# How do I save a front-end form as a specific Entry Type?

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

I have a few different forms on my site for different kinds of enquiries, each represented by an Entry Type with different fields in a single Enquiries channel. How can I get the entries/saveEntry form to save as a specific entry type?
My existing form:




I have two entry types in that channel, ID 111 and 112. When I add the line:


then submit the form, I get an error message saying "Unable to find the template 'hire-us/enquiryPlanningEvent'". It appears that Craft is looking for a template named after the entry type I'm trying to save, but obviously there isn't one.
What's the solution to this?

**Tags:** entries, form, entry-type, guest-entries
> **Comments:**
> **username_1**: If you enable [Dev Mode](http://buildwithcraft.com/help/dev-mode) Craft will give you a full stack trace when that error occurs. That may give you more insight into why it’s happening.  
> **username_0**: No stack trace I'm afraid Brandon - I'm seeing this error: http://i.imgur.com/aYj2a3d.png  
> **username_1**: Do you have any idea how that template is getting invoked? Maybe via the `redirect` param?  
> **username_0**: I did solve this - but I don't know why the error I got was happening. Basically if the `Title` field is expecting a value (i.e. not set automatically), and I submit the form without setting a title, then it redirects me to a template with the same handle as the Entry Type I was trying to submit to (regardless of the `redirect` value). Bug?  
> **username_0**: Actually it's not just if the Title field is missing, it happens if any required field has no data. Filing a bug report. Expected behaviour is that it should reload the page and call the errorList.  

---

## 3 answers

### Answer by username_0 on 2014-10-28. Score: 4 | Accepted answer

This has been solved via a support ticket, which I'm posting here for others etc.

The first time you load the template, the URI is mapping to your "Get
  A Quote" entry, which gets assigned to the entry variable when your
  template is loaded.
When you submit the form, the same URL is requested again, once again
  matching your "Get A Quote" entry, but this time the
  guestEntries/saveEntry controller action is summoned. When there's a
  validation error, Guest Entries will pass the new entry back to the
  template as an entry variable, overriding the "Get A Quote" entry that
  the URL matched. So, then the template gets routed to
  hire-us/index.html like it normally did, but this time entry.type is
  enquiryWeddingDance instead of getAQuote, since it's a different entry
  altogether. The template tries to include
  hire-us/enquiryWeddingDance.html, but that doesn't exist, so you get
  the error.
To fix this, I've just released an update to the Guest Entries plugin,
  which adds a new entryVariable config setting. You can use that to
  customize the variable name that Guest Entries will set the invalid
  entry to (i.e. 'guestEntry' or 'invalidEntry'), so it doesn't conflict
  with the entry variable that the request is getting routed to.

After setting the Guest Entries variable as suggested in the documentation, it's now working as expected without conflicts. Thanks Brandon!
Usage:
{% if guestEntry is defined %}{{ errorList(guestEntry.getErrors('variableName')) }}{% endif %}


---

### Answer by username_2 on 2014-10-22. Score: 1

I think the way you are trying to add entries requires authentication, if you look on the entry form page in the craft docs, you will see this snippet of text:

The user submitting the entry will also need to have the permission necessary to create entries for the section they are posting to

So I think you would need to use the guest entries plugin (from P&T), unless i'm mistaken, so maybe give that a try and see if it fixes the issue?
Guest Entries plugin on Github
The difference in markup is here:


This is the way I have done this on a site i've built and not had any issues, entries get saved and to the specified type. :)

> **Comments:**
> **username_0**: Thanks Alec - I've installed GuestEntries (updated question) but it's not solved the problem. When I submit the form, I get taken to the Template Error page in the question (http://i.imgur.com/aYj2a3d.png). It's something to do with the way I'm redirecting structure templates...  
> **username_0**: Alec - I'm guess the sites you've done in the past have used a different template routing structure. The error here isn't being caused by permissions, it's because the form is looking for a template that doesn't exist. No idea why it's looking for a template in the first place!  
> **username_2**: Added a new answer as it's completely unrelated to the guest entries answer :)  

---

### Answer by username_2 on 2014-10-28. Score: 1

Based on the comments from my other answer and seeing the image you sent.

Look in the template `hire-us/index.html` where you are trying to include a template dynamically with the `entry.type` variable, what that is generating does not correspond to a template you have, so it can't find the template to include and therefore you are getting the error.
As the error States craft is unable to find the template

Try removing the include altogether and just put `{{ entry.type }}` in the template and go through the process again so you can see what's being generated and get the name of the template you need to create to satisfy the include.

Hope that helps

> **Comments:**
> **username_0**: Hi Alec, thank you for all your help, but it turns out it was simpler than expected. Answered my own question, it was because the Title field was missing ><  
> **username_2**: Ahh no worries, glad you got things sorted in the end! :)  

---

