<p>Dropdowns are not relations, and therefore they don't need to be eager loaded (and indeed can't be eager loaded).</p>

<p>Here's an explanation of what's going on under the hood with eager loading: <a href="https://nystudio107.com/blog/speed-up-your-craft-cms-templates-with-eager-loading" rel="nofollow noreferrer">Speed up your Craft CMS Templates with Eager Loading</a></p>

<p>TL;DR only things that are <em>relations</em>, which are other Elements are candidates for eager loading. Other fields like Dropdowns, etc. are loaded as part of the content already.</p>

CC BY-SA 3.0
2017-11-20T00:54:44.060Z
2017-11-20T04:39:55.550Z
2017-11-20T04:39:55.550Z
andrew.welch
<p>I'm going through my current project and making my loops more "eager". It's working great in several areas and improving performance <em>massively</em> but for some reason I can't get it to work when the entries I'm asking for have a dropdown field. "newsType" is the name of the field. Am I missing some obvious mistake here or are dropdowns a special case somehow? </p>

<p>The error:</p>

<pre><code>Array to string conversion
echo twig_escape_filter($this-&gt;env, $this-&gt;getAttribute($context["article"], "newsType", array()), "html", null, true);
</code></pre>

<p>The code:</p>

<pre><code>{% set latestNews = {
    section : 'news',
    with : ['title', 'body', 'newsType'],
    limit : '6'
} %}

{% if latestNews|length %}
{% for article in craft.entries(latestNews) %}
    &lt;div class="newsEl {{ article.newsType }}"&gt;
    &lt;h2&gt;{{ article.newsType.label }}&lt;/h2&gt;
    &lt;article&gt;
       &lt;h3&gt;{{ article.title }}&lt;/h3&gt;
         &lt;p&gt;
           {{ article.body|striptags|slice(0, 150) ~ '...' }}
         &lt;/p&gt;
        &lt;/article&gt;
        &lt;a href="{{ article.url }}" class="readMore"&gt;Read More &lt;span&gt;&amp;rarr;&lt;/span&gt;&lt;/a&gt;
    &lt;/div&gt;
{% endfor %}
{% endif %}
</code></pre>

CC BY-SA 3.0
2017-11-20T00:54:12.927Z
Just read in a comment [here](https://craftcms.stackexchange.com/questions/18760/eager-loading-with-conditions) that eager loading only works with relational elements. So it's pointless to put a dropdown field in "with." Is this correct? If that's the case should I even be doing it for "title" and "body"?
James M
CC BY-SA 3.0
2017-11-20T00:55:55.423Z
Nope, you shouldn't be doing it for `title` or `body` either, assuming those are not relations to other Elements. `title` definitely won't be; `body` might be if it's a Matrix or some other Element.
andrew.welch
<eager-loading><drop-down>
How do I eager load a dropdown field?
# How do I eager load a dropdown field?

(Asked by: username_0 on 2017-11-20)

I'm going through my current project and making my loops more "eager". It's working great in several areas and improving performance massively but for some reason I can't get it to work when the entries I'm asking for have a dropdown field. "newsType" is the name of the field. Am I missing some obvious mistake here or are dropdowns a special case somehow? 
The error:
Array to string conversion
echo twig_escape_filter($this->env, $this->getAttribute($context["article"], "newsType", array()), "html", null, true);

The code:
{% set latestNews = {
    section : 'news',
    with : ['title', 'body', 'newsType'],
    limit : '6'
} %}

{% if latestNews|length %}
{% for article in craft.entries(latestNews) %}
    
    {{ article.newsType.label }}
    
       {{ article.title }}
         
           {{ article.body|striptags|slice(0, 150) ~ '...' }}
         
        
        Read More →
    
{% endfor %}
{% endif %}

**Tags:** eager-loading, drop-down
> **Comments:**
> **username_0**: Just read in a comment [here](https://craftcms.stackexchange.com/questions/18760/eager-loading-with-conditions) that eager loading only works with relational elements. So it's pointless to put a dropdown field in "with." Is this correct? If that's the case should I even be doing it for "title" and "body"?  
> **username_1**: Nope, you shouldn't be doing it for `title` or `body` either, assuming those are not relations to other Elements. `title` definitely won't be; `body` might be if it's a Matrix or some other Element.  

---

## 1 answers

### Answer by username_1 on 2017-11-20. Score: 1 | Accepted answer

Dropdowns are not relations, and therefore they don't need to be eager loaded (and indeed can't be eager loaded).

Here's an explanation of what's going on under the hood with eager loading: [Speed up your Craft CMS Templates with Eager Loading](https://nystudio107.com/blog/speed-up-your-craft-cms-templates-with-eager-loading)

TL;DR only things that are *relations*, which are other Elements are candidates for eager loading. Other fields like Dropdowns, etc. are loaded as part of the content already.


---

