I managed to make an entry type that won't let me create any entries. How can I fix it? 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-&gt;getAttribute((isset($context["object"]) ? $context["object"] : $this-&gt;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?
It sounds like you're trying to have a dynamic title 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. 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. 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.