Answers.Body: <p>It sounds like you're trying to have a <a href="https://craftcms.com/docs/sections-and-entries#dynamic-entry-titles" rel="nofollow noreferrer">dynamic title</a> for that section, based on an Entries field (Venue). Working out the nuances in this situation can be a little tricky, but I think this would do the trick for you:</p>
  
  <pre><code>{{ object.venue.first().title ?? '(no venue)' }}
  </code></pre>
  
  <p>Let's break down what's happening here...</p>
  
  <p>In this use-case, <code>object</code> is your Entry. Which means that <code>object.venue</code> is your Venue field (which happens to be an Entries field type).</p>
  
  <p>Since Venue is an Entries field type, that means it's going to return an <a href="https://craftcms.com/docs/templating/elementcriteriamodel" rel="nofollow noreferrer">Element Criteria Model</a>. When dealing with an ECM, you need to append something like <code>find()</code> (get all) or <code>first()</code> (get one) to end up with an actual, useful result.</p>
  
  <p>Once we've established that you only need a single Entry (<code>object.venue.first()</code>), let's go ahead and grab the title of that Entry (<code>object.venue.first().title</code>). The good news... that can all be chained together! The bad news... it'll throw an error if the Venue field is left empty.</p>
  
  <p>Which is where <code>?? '(no venue)'</code> comes in. The double question mark is called a <a href="https://straightupcraft.com/events/twigs-null-coalescing-operator" rel="nofollow noreferrer">null-coalescing operator</a>. It provides a graceful fallback, suppressing error messages and allowing you to provide a safe alternative.</p>
  
  <p>Put it all together, and you'll have a nice, <em>safe</em> dynamic title.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-05T03:28:27.893Z
Answers.LastActivityDate: 2017-07-05T03:28:27.893Z
Answers.UserDisplayName: Lindsey D
Body: <p>I managed to make an entry type that won't let me create any entries.</p>
  
  <p>The site is for a rock band, and the entry type in question is called "Shows". It contains five fields:</p>
  
  <ul>
  <li>Venue</li>
  <li>Lineup</li>
  <li>Date</li>
  <li>Time</li>
  <li>Body</li>
  </ul>
  
  <p>Date and Time are Date/Time fields, Lineup and Body are standard text fields. Venue is the field that I think is causing the trouble.</p>
  
  <p>Venue is an Entries field that lets you select one from several venues, which are entries in a separate section (a Structure) called Venues.</p>
  
  <p>When I enter data for a show, I'm able to select from the list of venues. When I try to save the Show, however, I get an error:</p>
  
  <blockquote>
    <p>Recoverable error: Object of class Craft\ElementCriteriaModel could not be converted to string.</p>
  </blockquote>
  
  <p>The most meaningful looking highlighted line in the debug output is:</p>
  
  <pre><code>echo $this-&gt;getAttribute((isset($context["object"]) ? $context["object"] : $this-&gt;getContext($context, "object")), "venue", array());
  </code></pre>
  
  <p>All these pages are in the admin section, not in my templates, thus they are pages I can't edit, so I don't know what I can do to fix this error. Is it possible that I have created an entry type that Craft can't handle? There doesn't seem to be anything that unusual about the Venue entry type.</p>
  
  <p>Have I done something obviously wrong? If not, how do I debug this?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T00:17:07.350Z
Comments.Text: Are you on the latest version of Craft? Try manually replacing your `craft/app` folder to ensure you don't have any missing or corrupt files.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T00:32:43.117Z
Comments.Text: Thanks for the suggestion, but manually replacing the app folder with the latest version (and clearing cache and reloading) made no change.
Comments.UserDisplayName: David Rhoden
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T00:38:00.470Z
Comments.Text: The file causing the error is in `/craft/storage/runtime/compiled_templates/`. Can I force Craft to recompile templates somehow?
Comments.UserDisplayName: David Rhoden
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T00:46:36.297Z
Comments.Text: You can safely delete the entire contents of the `runtime` folder. Not sure if that'll make a difference though.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T00:48:57.207Z
Comments.Text: If I click "Show the Title field" on, the admin page operates correctly. I really didn't want it on but I guess I'm formatting the Craft-generated title fields incorrectly, and that's where the error is really coming from.
Comments.UserDisplayName: David Rhoden
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T00:51:10.543Z
Comments.Text: Yup, that's the issue. Your dynamic title format is causing problems.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T00:52:00.413Z
Comments.Text: When you figure out the specific formatting issue, go ahead and post that below as an official answer! :)
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T02:01:39.497Z
Comments.Text: What's the pattern you're using? Maybe we can identify the issue.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T02:08:20.387Z
Comments.Text: Yes, and it's beyond my pay grade to figure it out.
  
  I started with `{venue}`, per the advice " You can include tags that output entry properties, such as {myCustomField}." I also tried `{venue.title}`. (The venue name is not an actual field in my entry type, it gets its value from the title.)
  
  Per https://craftcms.stackexchange.com/questions/1689/how-can-i-set-an-entry-title-automatically-based-on-a-related-entry ,
  I also tried `{{ object.shows.venue }}` and `{{ object.shows.first().venue }}`, which didn't work. I was not getting the debug page, just a message "Couldn't save entry."
Comments.UserDisplayName: David Rhoden
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T02:49:18.517Z
Comments.Text: Also `{{ entry.venue.title }}`. Thanks for all the help, by the way.
Comments.UserDisplayName: David Rhoden
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-05T02:55:12.227Z
Comments.Text: Which one are you using when you get that error?  You probably just need `entry.venue.first().title` (assuming you want to use the first selected venue for the title).
Comments.UserDisplayName: Brad Bell
Tags: <entries><admin><entry-type><entries-field>
Title: I managed to make an entry type that won't let me create any entries. How can I fix it?
ThreadText: # I managed to make an entry type that won't let me create any entries. How can I fix it?
  
  (Asked by: username_0 on 2017-07-04)
  
  I managed to make an entry type that won't let me create any entries.
  
  The site is for a rock band, and the entry type in question is called "Shows". It contains five fields:
  
  * Venue
  * Lineup
  * Date
  * Time
  * Body
  
  Date and Time are Date/Time fields, Lineup and Body are standard text fields. Venue is the field that I think is causing the trouble.
  
  Venue is an Entries field that lets you select one from several venues, which are entries in a separate section (a Structure) called Venues.
  
  When I enter data for a show, I'm able to select from the list of venues. When I try to save the Show, however, I get an error:
  
  > Recoverable error: Object of class Craft\ElementCriteriaModel could not be converted to string.
  
  The most meaningful looking highlighted line in the debug output is:
  
  ```
  echo $this->getAttribute((isset($context["object"]) ? $context["object"] : $this->getContext($context, "object")), "venue", array());
  
  ```
  
  All these pages are in the admin section, not in my templates, thus they are pages I can't edit, so I don't know what I can do to fix this error. Is it possible that I have created an entry type that Craft can't handle? There doesn't seem to be anything that unusual about the Venue entry type.
  
  Have I done something obviously wrong? If not, how do I debug this?
  
  **Tags:** entries, admin, entry-type, entries-field
  
  > **Comments:**
  > **username_1**: Are you on the latest version of Craft? Try manually replacing your `craft/app` folder to ensure you don't have any missing or corrupt files.  
  > **username_0**: Thanks for the suggestion, but manually replacing the app folder with the latest version (and clearing cache and reloading) made no change.  
  > **username_0**: The file causing the error is in `/craft/storage/runtime/compiled_templates/`. Can I force Craft to recompile templates somehow?  
  > **username_1**: You can safely delete the entire contents of the `runtime` folder. Not sure if that'll make a difference though.  
  > **username_0**: If I click "Show the Title field" on, the admin page operates correctly. I really didn't want it on but I guess I'm formatting the Craft-generated title fields incorrectly, and that's where the error is really coming from.  
  > **username_1**: Yup, that's the issue. Your dynamic title format is causing problems.  
  > **username_1**: When you figure out the specific formatting issue, go ahead and post that below as an official answer! :)  
  > **username_1**: What's the pattern you're using? Maybe we can identify the issue.  
  > **username_0**: Yes, and it's beyond my pay grade to figure it out.  I started with `{venue}`, per the advice " You can include tags that output entry properties, such as {myCustomField}." I also tried `{venue.title}`. (The venue name is not an actual field in my entry type, it gets its value from the title.)  Per https://craftcms.stackexchange.com/questions/1689/how-can-i-set-an-entry-title-automatically-based-on-a-related-entry , I also tried `{{ object.shows.venue }}` and `{{ object.shows.first().venue }}`, which didn't work. I was not getting the debug page, just a message "Couldn't save entry."  
  > **username_0**: Also `{{ entry.venue.title }}`. Thanks for all the help, by the way.  
  > **username_2**: Which one are you using when you get that error?  You probably just need `entry.venue.first().title` (assuming you want to use the first selected venue for the title).  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-07-05. Score: 2 | Accepted answer
  
  It sounds like you're trying to have a [dynamic title](https://craftcms.com/docs/sections-and-entries#dynamic-entry-titles) for that section, based on an Entries field (Venue). Working out the nuances in this situation can be a little tricky, but I think this would do the trick for you:
  
  ```
  {{ object.venue.first().title ?? '(no venue)' }}
  
  ```
  
  Let's break down what's happening here...
  
  In this use-case, `object` is your Entry. Which means that `object.venue` is your Venue field (which happens to be an Entries field type).
  
  Since Venue is an Entries field type, that means it's going to return an [Element Criteria Model](https://craftcms.com/docs/templating/elementcriteriamodel). When dealing with an ECM, you need to append something like `find()` (get all) or `first()` (get one) to end up with an actual, useful result.
  
  Once we've established that you only need a single Entry (`object.venue.first()`), let's go ahead and grab the title of that Entry (`object.venue.first().title`). The good news... that can all be chained together! The bad news... it'll throw an error if the Venue field is left empty.
  
  Which is where `?? '(no venue)'` comes in. The double question mark is called a [null-coalescing operator](https://straightupcraft.com/events/twigs-null-coalescing-operator). It provides a graceful fallback, suppressing error messages and allowing you to provide a safe alternative.
  
  Put it all together, and you'll have a nice, *safe* dynamic title.
  
  
  ---
  
  