<p>The error message indicates that a field with the handle <code>topics</code> doesn't exist. You need to use the field handle defined in the field's settings. Go to <strong>Settings ⇾ Fields ⇾ Topics</strong> (the name of your field), the second input below the name will show you the field handle you need to use, and allow you to change it.</p>
<p>You can also display field handles in element forms in the Control Panel as a convenience. Go to your profile settings and activate the option <strong>Show field handles in edit forms</strong>, which is inactive by default.</p>

CC BY-SA 4.0
2023-09-05T14:42:30.987Z
Thanks for this - I changed setting the variable value to that of the field handle and that worked - thanks. Definitely different from how the Tutorial says to do it.
GeordieJS
CC BY-SA 4.0
2023-09-06T15:49:20.503Z
@GeordieJS The tutorial shows the handle `topics` in the screenshot for the categories field: https://craftcms.com/docs/getting-started-tutorial/configure/resources.html#create-a-category-group And this should be the default handle that is created when you enter `Topics` as the field name. The handle is only generated based on the field name when the field is created, after that you have to update it manually if you want to use a different handle.
MoritzLost
CC BY-SA 4.0
2023-09-05T13:58:23.883Z
2023-09-05T13:58:23.883Z
MoritzLost
<p>I'm working through the '<strong>getting started</strong>' tutorial and I've run into an error I can't get passed. I've created the Category Group: 'Topics' and then created the Field 'PostCategories' and connected it to the Topics Category Group. I've added this to my 'post' entry type along with the other fields mentioned in the Tutorial.</p>
<p>I've copied the code for the '_entry.twig' template (see attached) which when I run throws a runtime error: <code>Calling unknown method: craft\elements\Entry::topics()</code>'</p>
<p>I had noticed that there was an inconsistency in the instructions for creating the 'Category Group' but even when I changed to match either option shown for creating a 'Category URI Format' the error appeared. <a href="https://i.sstatic.net/vQISD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/vQISD.png" alt="There's an inconsistency in the instructions here" /></a><a href="https://i.sstatic.net/H3EzZ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/H3EzZ.png" alt="This is the code that declares the 'Topic' variable, then calls it in a loop" /></a></p>
<p>I'm a total noob at this so thanks in advance for any pointers.</p>

<templating><categories>
Twig Runtime Error on Craft 4 Getting Started Tutorial
# Twig Runtime Error on Craft 4 Getting Started Tutorial

(Asked by: username_0 on 2023-09-05)

I'm working through the '**getting started**' tutorial and I've run into an error I can't get passed. I've created the Category Group: 'Topics' and then created the Field 'PostCategories' and connected it to the Topics Category Group. I've added this to my 'post' entry type along with the other fields mentioned in the Tutorial.

I've copied the code for the '\_entry.twig' template (see attached) which when I run throws a runtime error: `Calling unknown method: craft\elements\Entry::topics()`'

I had noticed that there was an inconsistency in the instructions for creating the 'Category Group' but even when I changed to match either option shown for creating a 'Category URI Format' the error appeared. [![There's an inconsistency in the instructions here](https://i.sstatic.net/vQISD.png)](https://i.sstatic.net/vQISD.png)[![This is the code that declares the 'Topic' variable, then calls it in a loop](https://i.sstatic.net/H3EzZ.png)](https://i.sstatic.net/H3EzZ.png)

I'm a total noob at this so thanks in advance for any pointers.

**Tags:** templating, categories


---

## 1 answers

### Answer by username_1 on 2023-09-05. Score: 1 | Accepted answer

The error message indicates that a field with the handle `topics` doesn't exist. You need to use the field handle defined in the field's settings. Go to **Settings ⇾ Fields ⇾ Topics** (the name of your field), the second input below the name will show you the field handle you need to use, and allow you to change it.

You can also display field handles in element forms in the Control Panel as a convenience. Go to your profile settings and activate the option **Show field handles in edit forms**, which is inactive by default.

> **Comments:**
> **username_0**: Thanks for this - I changed setting the variable value to that of the field handle and that worked - thanks. Definitely different from how the Tutorial says to do it.  
> **username_1**: @username_0 The tutorial shows the handle `topics` in the screenshot for the categories field: https://craftcms.com/docs/getting-started-tutorial/configure/resources.html#create-a-category-group And this should be the default handle that is created when you enter `Topics` as the field name. The handle is only generated based on the field name when the field is created, after that you have to update it manually if you want to use a different handle.  

---

