Answers.Body: <p>You can loop through all of the selected values of a multi-select field like this:</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>{% for value in entry.myFieldHandle %}
    &lt;li&gt;{{ value }}&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
  <p>(See the <a href="http://buildwithcraft.com/docs/multi-select-fields#templating" rel="nofollow">Multi-select field docs</a> for other examples.)</p>
  
  <p>The easiest way to loop through <em>all</em> of your multi-select fields’ values would be to manually merge all of their values into a new array:</p>
  
  <pre class="lang-html prettyprint-override"><code>{% set values = entry.fieldHandleOne
      |merge([entry.fieldHandleTwo])
      |merge([entry.fieldHandleThree]) %}
  
  {% for value in values %}
      {{ value }}
  {% endfor %}
  </code></pre>
  
  <p>If you really don’t want to hardcode the field handles in your template, then you can go the getFieldLayout() route. That <code>field.getField()</code> function will give you the actual <a href="http://buildwithcraft.com/classreference/models/FieldModel" rel="nofollow">FieldModel</a> that represents the field. You can use its <code>handle</code> property to access the field’s selected values on your <code>entry</code>:</p>
  
  <pre class="lang-html prettyprint-override"><code>{% set values = [] %}
  
  {% for tab in entry.getFieldLayout().getTabs() %}
    {% if tab.name == 'Spec' %}
      {% for field in tab.getFields() %}
        {% set handle = field.getField().handle %}
        {% set fieldValues = entry.getFieldValue(handle) %}
        {% set values = values|merge([fieldValues]) %}
      {% endfor %}
    {% endif %}
  {% endfor %}
  
  {% for value in values %}
    {% for selected in value %}
      &lt;li&gt;{{ selected}}&lt;/li&gt;
    {% endfor %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-20T08:46:02.737Z
Answers.Text: Hi, thank you for response. I have been trying your solution, but I get this error `The merge filter only works with arrays or hashes; array and object given.`.
Answers.UserDisplayName: Ivaylo Petrov
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-20T08:58:57.003Z
Answers.Text: I made a quick search and solve the problem adding square brackets `{% set values = values|merge([fieldValues]) %}` and another loop to print the values `{% for value in values %} {% for selected in value %}  <li>{{ selected }}</li>
  {% endfor %} {% endfor %}`. If There is a better solution I will be glad to know it. Thanks for help.
Answers.UserDisplayName: Ivaylo Petrov
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-20T20:12:11.583Z
Answers.Text: @IvayloPetrov Whoops, sorry about that! Just fixed the code.
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-21T06:53:57.663Z
Answers.Text: Don`t worry, we all are humans ;) You miss to fix last code example :) I fixed it :)
Answers.UserDisplayName: Ivaylo Petrov
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-19T22:25:27.950Z
Answers.LastActivityDate: 2015-10-21T13:32:15.303Z
Answers.LastEditDate: 2015-10-21T13:32:15.303Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I am new in Craft, and will be happy if I can get help with this task. I have a tab that contains only multiselect fields. What I want to do, is to get all selected values for all multiselects field in this tab. I find this <a href="https://craftcms.stackexchange.com/a/5253/4109">answer</a> to get all field from a tab, but I can't get the selected values for the entry. Here is my code:</p>
  
  <pre><code>{% for tab in entry.getFieldLayout().getTabs() %}
    {% if tab.name == 'Spec' %}
      &lt;ul&gt;
        &lt;li&gt;{{ tab.name }}
          &lt;ul&gt;
            {% for field in tab.getFields() %}
              &lt;li&gt;{{ field.getField().name }}&lt;/li&gt;
            {% endfor %}
          &lt;/ul&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
    {% endif %}
  {% endfor %}
  </code></pre>
  
Tags: <templating>
Title: Get selected values from all of an entry’s Multi-select fields
ThreadText: # Get selected values from all of an entry’s Multi-select fields
  
  (Asked by: username_0 on 2015-10-19)
  
  I am new in Craft, and will be happy if I can get help with this task. I have a tab that contains only multiselect fields. What I want to do, is to get all selected values for all multiselects field in this tab. I find this [answer](https://craftcms.stackexchange.com/a/5253/4109) to get all field from a tab, but I can't get the selected values for the entry. Here is my code:
  
  ```
  {% for tab in entry.getFieldLayout().getTabs() %}
    {% if tab.name == 'Spec' %}
      <ul>
        <li>{{ tab.name }}
          <ul>
            {% for field in tab.getFields() %}
              <li>{{ field.getField().name }}</li>
            {% endfor %}
          </ul>
        </li>
      </ul>
    {% endif %}
  {% endfor %}
  
  ```
  
  **Tags:** templating
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-10-19. Score: 2 | Accepted answer
  
  You can loop through all of the selected values of a multi-select field like this:
  
  ```html
  {% for value in entry.myFieldHandle %}
    <li>{{ value }}</li>
  {% endfor %}
  
  ```
  
  (See the [Multi-select field docs](http://buildwithcraft.com/docs/multi-select-fields#templating) for other examples.)
  
  The easiest way to loop through *all* of your multi-select fields’ values would be to manually merge all of their values into a new array:
  
  ```html
  {% set values = entry.fieldHandleOne
      |merge([entry.fieldHandleTwo])
      |merge([entry.fieldHandleThree]) %}
  
  {% for value in values %}
      {{ value }}
  {% endfor %}
  
  ```
  
  If you really don’t want to hardcode the field handles in your template, then you can go the getFieldLayout() route. That `field.getField()` function will give you the actual [FieldModel](http://buildwithcraft.com/classreference/models/FieldModel) that represents the field. You can use its `handle` property to access the field’s selected values on your `entry`:
  
  ```html
  {% set values = [] %}
  
  {% for tab in entry.getFieldLayout().getTabs() %}
    {% if tab.name == 'Spec' %}
      {% for field in tab.getFields() %}
        {% set handle = field.getField().handle %}
        {% set fieldValues = entry.getFieldValue(handle) %}
        {% set values = values|merge([fieldValues]) %}
      {% endfor %}
    {% endif %}
  {% endfor %}
  
  {% for value in values %}
    {% for selected in value %}
      <li>{{ selected}}</li>
    {% endfor %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Hi, thank you for response. I have been trying your solution, but I get this error `The merge filter only works with arrays or hashes; array and object given.`.  
  > **username_0**: I made a quick search and solve the problem adding square brackets `{% set values = values|merge([fieldValues]) %}` and another loop to print the values `{% for value in values %} {% for selected in value %}  <li>{{ selected }}</li> {% endfor %} {% endfor %}`. If There is a better solution I will be glad to know it. Thanks for help.  
  > **username_1**: @username_0 Whoops, sorry about that! Just fixed the code.  
  > **username_0**: Don`t worry, we all are humans ;) You miss to fix last code example :) I fixed it :)  
  
  ---
  
  