<p>This is basically just a syntax error. What you are doing is: searching for entries in the group <code>section: 'markets', with: ['bannerImage']</code> but what you want is searching for categories in the group <code>markets</code> with the field <code>bannerImage</code></p>

<pre><code>{% set markets = craft.categories.group('markets').with(['bannerImage']).all() %}
</code></pre>

<p>The <code>group</code> parameter in your <code>CategoryQuery</code> defined which group(s) you want to select. The <code>with</code> parameter your eager-loading elements. Btw: <code>Categories</code> have no <code>section</code> property</p>

CC BY-SA 3.0
2018-03-29T11:35:01.600Z
2018-03-29T11:35:01.600Z
Robin Schambach
<p>Is it possible to eagerLoad fields in categories?</p>

<p>I have this code;</p>

<pre><code>{% set markets = craft.categories.group({
  section: 'markets',
  with: ['bannerImage']
}) %}
</code></pre>

<p>which for some reason is throwing an error;</p>

<blockquote>
  <p>mb_convert_case() expects parameter 1 to be string, array given</p>
</blockquote>

<p>Is this a bug or something bad in my code? Removing the with call and it renders fine.</p>

<categories><eager-loading>
Eager loading fields within categories
# Eager loading fields within categories

(Asked by: username_0 on 2018-03-29)

Is it possible to eagerLoad fields in categories?
I have this code;
{% set markets = craft.categories.group({
  section: 'markets',
  with: ['bannerImage']
}) %}

which for some reason is throwing an error;

mb_convert_case() expects parameter 1 to be string, array given

Is this a bug or something bad in my code? Removing the with call and it renders fine.

**Tags:** categories, eager-loading


---

## 1 answers

### Answer by username_1 on 2018-03-29. Score: 3 | Accepted answer

This is basically just a syntax error. What you are doing is: searching for entries in the group section: 'markets', with: ['bannerImage'] but what you want is searching for categories in the group markets with the field bannerImage
{% set markets = craft.categories.group('markets').with(['bannerImage']).all() %}

The group parameter in your CategoryQuery defined which group(s) you want to select. The with parameter your eager-loading elements. Btw: Categories have no section property


---

