Answers.Body: <p>In your example, <code>checkbox</code> is an instance of <a href="http://buildwithcraft.com/classreference/fieldtypes/MultiOptionsFieldData" rel="nofollow">MultiOptionsFieldData</a>, which behaves like an array of all of the possible checkbox options.</p>
  
  <p>It doesn't have a <code>__toString()</code> method on it, which is why you're getting the error.</p>
  
  <p>I assume what you want to be doing is grouping by a selected checkbox, no?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-21T15:33:37.390Z
Answers.Text: I expected to be able to do the a similar thing with categories, but think I'm running into the same thing: ```{% set entries = craft.entries.section('media').find() %}
  {% set entriesByCat = entries|group('mediaCategory') %}
  ``` Can we just not use `.group` like this?
Answers.UserDisplayName: Tim Kelty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-21T15:53:28.850Z
Answers.Text: I meant `|group`, as in the filter :)
Answers.UserDisplayName: Tim Kelty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-21T16:28:58.117Z
Answers.Text: Added a related recipe: http://craftcookbook.net/recipes/330
Answers.UserDisplayName: Tim Kelty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-21T16:29:24.857Z
Answers.Text: It would be nice if `group` was aware of `Craft\ElementCriteriaModel`s, so you could do something like:```{% set entriesByCat = entries|group('myCategory.slug') %}```
Answers.UserDisplayName: Tim Kelty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-21T16:31:33.460Z
Answers.Text: Though maybe that's a better case for a `groupCriteria` filter or something...ok I'll stop adding comments now.
Answers.UserDisplayName: Tim Kelty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-25T15:00:28.003Z
Answers.Text: @paul, I just made a plugin to make this kind of grouping easier: https://github.com/timkelty/groupby-craft
Answers.UserDisplayName: Tim Kelty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-19T21:29:49.240Z
Answers.LastActivityDate: 2014-11-19T21:29:49.240Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>What Brad says, plus an example of grouping by selected checkbox:</p>
  
  <pre><code>{% set entries = craft.entries.section('my_entries') %}
  
  {# get all checkbox options #}
  {% set options = entries.first().checkbox.options %}
  
  {% for option in options %}
      &lt;h2&gt;{{ option }}&lt;/h2&gt;
      &lt;ul&gt;
      {% for entry in entries if entry.checkbox.contains(option) %}
         &lt;li&gt;{{ entry.title }}&lt;/li&gt;
      {% endfor %}
      &lt;/ul&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-19T21:33:19.283Z
Answers.LastActivityDate: 2014-11-19T21:38:33.430Z
Answers.LastEditDate: 2014-11-19T21:38:33.430Z
Answers.UserDisplayName: Paul
Body: <p>We're looking to output a list of entries and group them by their check box values. Here's what we've got so far:</p>
  
  <pre><code>{% for checkbox, entries in craft.entries.section('my_entries').find() | group('checkbox') %}
     {{ checkbox }}
  {% endfor %}
  </code></pre>
  
  <p>This currently returns "Object of class Craft\MultiOptionsFieldData could not be converted to string".</p>
  
  <p>Any ideas? Is this even possible?</p>
  
Tags: <entries><group>
Title: Is it possible to group entries by checkbox?
ThreadText: # Is it possible to group entries by checkbox?
  
  (Asked by: username_0 on 2014-11-19)
  
  We're looking to output a list of entries and group them by their check box values. Here's what we've got so far:
  
  ```
  {% for checkbox, entries in craft.entries.section('my_entries').find() | group('checkbox') %}
     {{ checkbox }}
  {% endfor %}
  
  ```
  
  This currently returns "Object of class Craft\MultiOptionsFieldData could not be converted to string".
  
  Any ideas? Is this even possible?
  
  **Tags:** entries, group
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2014-11-19. Score: 6 | Accepted answer
  
  What username_1 says, plus an example of grouping by selected checkbox:
  
  ```
  {% set entries = craft.entries.section('my_entries') %}
  
  {# get all checkbox options #}
  {% set options = entries.first().checkbox.options %}
  
  {% for option in options %}
      <h2>{{ option }}</h2>
      <ul>
      {% for entry in entries if entry.checkbox.contains(option) %}
         <li>{{ entry.title }}</li>
      {% endfor %}
      </ul>
  {% endfor %}
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2014-11-19. Score: 1
  
  In your example, `checkbox` is an instance of [MultiOptionsFieldData](http://buildwithcraft.com/classreference/fieldtypes/MultiOptionsFieldData), which behaves like an array of all of the possible checkbox options.
  
  It doesn't have a `__toString()` method on it, which is why you're getting the error.
  
  I assume what you want to be doing is grouping by a selected checkbox, no?
  
  > **Comments:**
  > **username_2**: I expected to be able to do the a similar thing with categories, but think I'm running into the same thing: ```{% set entries = craft.entries.section('media').find() %} {% set entriesByCat = entries|group('mediaCategory') %} ``` Can we just not use `.group` like this?  
  > **username_2**: I meant `|group`, as in the filter :)  
  > **username_2**: Added a related recipe: http://craftcookbook.net/recipes/330  
  > **username_2**: It would be nice if `group` was aware of `Craft\ElementCriteriaModel`s, so you could do something like:```{% set entriesByCat = entries|group('myCategory.slug') %}```  
  > **username_2**: Though maybe that's a better case for a `groupCriteria` filter or something...ok I'll stop adding comments now.  
  > **username_2**: @username_3, I just made a plugin to make this kind of grouping easier: https://github.com/username_2/groupby-craft  
  
  ---
  
  