Answers.Body: <p>You'll want to use <code>block.icon.first()</code> if you just want the first Asset, or you could loop through all Assets:</p>
  
  <pre><code>{% for block in entry.visitorContentBuilder %}
  
      {% if block.type == "listItemWithIcon" %}
  
          &lt;ul&gt;
              {% for icon in block.icon %}
                  &lt;li&gt;{{ icon }}
              {% endfor %}
          &lt;/ul&gt;
  
      {% endif %}
  
  {% endfor %}
  </code></pre>
  
  <p>See <a href="https://craftcms.stackexchange.com/questions/265/what-are-the-differences-between-an-elementcriteriamodel-and-fetched-elements">here</a> for a description of the difference between an ElementCriteriaModel and actual fetched elements in Craft.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-02T12:24:14.520Z
Answers.Text: Thank you! That solved it for me. Also, in this particular case {{block.icon.first.url}} produced the path that I was actually looking for. I wish there was some sort of "default" output for {{ block.icon }} instead of an error.
Answers.UserDisplayName: Panos Spiliotis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-01T17:30:27.023Z
Answers.LastActivityDate: 2017-08-01T17:30:27.023Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have set up a Matrix field that contains a block type that contains among other things, an asset field. 
  Trying to iterate through the contents of that matrix field works just fine for all other field types but produces the following error when it comes across the asset field type.</p>
  
  <blockquote>
    <p>Object of class Craft\ElementCriteriaModel could not be converted to string</p>
  </blockquote>
  
  <p>This is the part of the template that produces the error. "icon" is the asset field type.</p>
  
  <pre><code>{% for block in entry.visitorContentBuilder %}
  
      {% if block.type == "listItemWithIcon" %}
  
          {{ block.icon }}
  
      {% endif %}
  
  {% endfor %}
  </code></pre>
  
Tags: <assets><matrix><assetfilemodel>
Title: Object of class Craft\ElementCriteriaModel could not be converted to string
ThreadText: # Object of class Craft\ElementCriteriaModel could not be converted to string
  
  (Asked by: username_0 on 2017-08-01)
  
  I have set up a Matrix field that contains a block type that contains among other things, an asset field.
  Trying to iterate through the contents of that matrix field works just fine for all other field types but produces the following error when it comes across the asset field type.
  
  > Object of class Craft\ElementCriteriaModel could not be converted to string
  
  This is the part of the template that produces the error. "icon" is the asset field type.
  
  ```
  {% for block in entry.visitorContentBuilder %}
  
      {% if block.type == "listItemWithIcon" %}
  
          {{ block.icon }}
  
      {% endif %}
  
  {% endfor %}
  
  ```
  
  **Tags:** assets, matrix, assetfilemodel
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-08-01. Score: 2 | Accepted answer
  
  You'll want to use `block.icon.first()` if you just want the first Asset, or you could loop through all Assets:
  
  ```
  {% for block in entry.visitorContentBuilder %}
  
      {% if block.type == "listItemWithIcon" %}
  
          <ul>
              {% for icon in block.icon %}
                  <li>{{ icon }}
              {% endfor %}
          </ul>
  
      {% endif %}
  
  {% endfor %}
  
  ```
  
  See [here](https://craftcms.stackexchange.com/questions/265/what-are-the-differences-between-an-elementcriteriamodel-and-fetched-elements) for a description of the difference between an ElementCriteriaModel and actual fetched elements in Craft.
  
  > **Comments:**
  > **username_0**: Thank you! That solved it for me. Also, in this particular case {{block.icon.first.url}} produced the path that I was actually looking for. I wish there was some sort of "default" output for {{ block.icon }} instead of an error.  
  
  ---
  
  