Answers.Body: <p>Try something like this (completely untested):</p>
  
  <pre><code>{# Grab all categories in the group and set variable. #}
  {% set categories = craft.categories.group('designCategories') %}
  
  {# Grab the categories Ids that the user already selected #}
  {% set userOptionIds = user.designOptions.limit(null).ids() %}
  
  {# Display all category checkboxes in the form, with the logged in user's saved selections already checked.#}
  {% for category in categories %}
      &lt;input type="checkbox" id="designOptions" name="fields[designsOptions][]" {% if category.id in userOptionIds %}checked{% endif %} value=" {{ category.id }}"&gt;
          {{ category.title }}
      &lt;/input&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-05T23:34:56.100Z
Answers.LastActivityDate: 2014-09-05T23:34:56.100Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>I realize this thread has an accepted answer, but I wanted to <a href="https://craftcms.stackexchange.com/questions/11595/how-do-i-handle-and-or-repopulate-checkbox-groups/12550#12550">provide another solution</a> I was able to come up with because of the answer Brad provided. In my example, I am working with a plugin, but the twig/html is the same plugin or not.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-25T18:40:14.930Z
Answers.LastActivityDate: 2015-11-25T18:40:14.930Z
Answers.LastEditDate: 2017-04-13T12:51:00.253Z
Answers.UserDisplayName: Damon
Answers.Body: <p>This answer was incredibly helpful in creating a dropdown solution for my scenario of selecting a school from a category for a user profile on a front end form.  It's structured nearly identically as above but as a dropdown selector.</p>
  <pre><code>&lt;div class=&quot;form-group&quot;&gt;
      &lt;label&gt;School Attended&lt;/label&gt;
      {% set categories = craft.categories.group('school').all() %}
      {% set userOptionIds = currentUser.schoolAttended.limit(null).ids() %}
          &lt;select name=&quot;fields[schoolAttended][]&quot; class=&quot;form-control&quot;&gt;
          {% for category in categories %}
              &lt;option id=&quot;schoolAttended&quot; name=&quot;fields[schoolAttended][]&quot; {% if category.id in userOptionIds %}selected{% endif %} value=&quot; {{ category.id }}&quot;&gt;
              {{ category.title }}
              &lt;/option&gt;
          {% endfor %}
          &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  <p>I hope this helps someone else find the answer they need but I'm also open to suggestions that may improve the result.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-01T05:42:05.560Z
Answers.LastActivityDate: 2020-09-02T03:55:36.773Z
Answers.LastEditDate: 2020-09-02T03:55:36.773Z
Answers.UserDisplayName: Cynder Gray
Body: <p>I have a user field called "designOptions" that is a Categories Checkbox field type. I have this field in the Edit Profile front-end form so that the user can see the saved options that they had selected previously (if any) and then change or add to those selections in the Edit Profile form. I am having a hard time finding anything in the documentation or SE about how to display all of the user's category checkbox options while displaying the options that are already selected in their account for that field. This is what I have so far, but it is checking all category options instead of just the 4 that the user has selected - likely because the length conditional is only looking at whether this field has 'any' value and not checking the value of each option.</p>
  
  <p>I would appreciate any guidance you can give on the best way to do this. :)</p>
  
  <p>Thank you!</p>
  
  <pre><code>{# Grab all categories in the group and set variable. #}
  {% set categories = craft.categories.group('designCategories') %}
  
  {# Grab the categories that the user already selected #}
  {% set userOptions = user.designOptions %}
  
  {# Display all category checkboxes in the form, with the logged in user's saved selections already checked.#}
  {% for category in categories %}
      &lt;input type="checkbox" id="designOptions" name="fields[designsOptions][]" {% if userOptions | length %}checked{% endif %} value=" {{ category.id }}"&gt; {{ category.title }}&lt;/input&gt;
  {% endfor %}
  </code></pre>
  
  <p><img src="https://i.sstatic.net/LwAJ5.jpg" alt="Design Categories"><img src="https://i.sstatic.net/0nNfE.png" alt="Design Options User Field with Design Categories as Source"><img src="https://i.sstatic.net/usjLA.png" alt="Categories already selected by User"><img src="https://i.sstatic.net/T4Pc3.png" alt="Trying to display all categories as well as the categories already selected by the user on the &quot;Edit Profile&quot; front end page."></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-05T19:46:00.477Z
Comments.Text: I'm a little confused... "designOptions" is a Checkboxes field type that's on your User field layout, correct? What's the relationship between "designOptions" and your category group, "designCategories"?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-05T20:54:37.840Z
Comments.Text: I created a User field 'designOptions' that is a "Category Field Type" which calls on options from the category group (designCategories). On the Edit Profile page, I would like to display all of those categories as checkboxes with the options already saved showing as checked. This will allow the user to either uncheck current categories or check new categories in the "Edit Profile" form.
Comments.UserDisplayName: Angela
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-05T22:22:53.527Z
Comments.Text: I'm not sure that helps my brain. :)  Can you post some screenshots in the original question of all of the involved fields and what field layouts they are attached to?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-09-05T23:05:04.157Z
Comments.Text: Here you go @BradBell Hopefully this will help. :)
Comments.UserDisplayName: Angela
Tags: <user-profile>
Title: Display a user's selected checkbox options for a category field type in a front-end Edit Profile form
ThreadText: # Display a user's selected checkbox options for a category field type in a front-end Edit Profile form
  
  (Asked by: username_0 on 2014-09-05)
  
  I have a user field called "designOptions" that is a Categories Checkbox field type. I have this field in the Edit Profile front-end form so that the user can see the saved options that they had selected previously (if any) and then change or add to those selections in the Edit Profile form. I am having a hard time finding anything in the documentation or SE about how to display all of the user's category checkbox options while displaying the options that are already selected in their account for that field. This is what I have so far, but it is checking all category options instead of just the 4 that the user has selected - likely because the length conditional is only looking at whether this field has 'any' value and not checking the value of each option.
  
  I would appreciate any guidance you can give on the best way to do this. :)
  
  Thank you!
  
  ```
  {# Grab all categories in the group and set variable. #}
  {% set categories = craft.categories.group('designCategories') %}
  
  {# Grab the categories that the user already selected #}
  {% set userOptions = user.designOptions %}
  
  {# Display all category checkboxes in the form, with the logged in user's saved selections already checked.#}
  {% for category in categories %}
      <input type="checkbox" id="designOptions" name="fields[designsOptions][]" {% if userOptions | length %}checked{% endif %} value=" {{ category.id }}"> {{ category.title }}</input>
  {% endfor %}
  
  ```
  
  ![Design Categories](https://i.sstatic.net/LwAJ5.jpg)![Design Options User Field with Design Categories as Source](https://i.sstatic.net/0nNfE.png)![Categories already selected by User](https://i.sstatic.net/usjLA.png)![Trying to display all categories as well as the categories already selected by the user on the "Edit Profile" front end page.](https://i.sstatic.net/T4Pc3.png)
  
  **Tags:** user-profile
  
  > **Comments:**
  > **username_1**: I'm a little confused... "designOptions" is a Checkboxes field type that's on your User field layout, correct? What's the relationship between "designOptions" and your category group, "designCategories"?  
  > **username_0**: I created a User field 'designOptions' that is a "Category Field Type" which calls on options from the category group (designCategories). On the Edit Profile page, I would like to display all of those categories as checkboxes with the options already saved showing as checked. This will allow the user to either uncheck current categories or check new categories in the "Edit Profile" form.  
  > **username_1**: I'm not sure that helps my brain. :)  Can you post some screenshots in the original question of all of the involved fields and what field layouts they are attached to?  
  > **username_0**: Here you go @username_1 Hopefully this will help. :)  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2014-09-05. Score: 1 | Accepted answer
  
  Try something like this (completely untested):
  
  ```
  {# Grab all categories in the group and set variable. #}
  {% set categories = craft.categories.group('designCategories') %}
  
  {# Grab the categories Ids that the user already selected #}
  {% set userOptionIds = user.designOptions.limit(null).ids() %}
  
  {# Display all category checkboxes in the form, with the logged in user's saved selections already checked.#}
  {% for category in categories %}
      <input type="checkbox" id="designOptions" name="fields[designsOptions][]" {% if category.id in userOptionIds %}checked{% endif %} value=" {{ category.id }}">
          {{ category.title }}
      </input>
  {% endfor %}
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2015-11-25. Score: 1
  
  I realize this thread has an accepted answer, but I wanted to [provide another solution](https://craftcms.stackexchange.com/questions/11595/how-do-i-handle-and-or-repopulate-checkbox-groups/12550#12550) I was able to come up with because of the answer username_1 provided. In my example, I am working with a plugin, but the twig/html is the same plugin or not.
  
  
  ---
  
  ### Answer by username_3 on 2020-09-01. Score: 1
  
  This answer was incredibly helpful in creating a dropdown solution for my scenario of selecting a school from a category for a user profile on a front end form. It's structured nearly identically as above but as a dropdown selector.
  
  ```
  <div class="form-group">
      <label>School Attended</label>
      {% set categories = craft.categories.group('school').all() %}
      {% set userOptionIds = currentUser.schoolAttended.limit(null).ids() %}
          <select name="fields[schoolAttended][]" class="form-control">
          {% for category in categories %}
              <option id="schoolAttended" name="fields[schoolAttended][]" {% if category.id in userOptionIds %}selected{% endif %} value=" {{ category.id }}">
              {{ category.title }}
              </option>
          {% endfor %}
          </select>
  </div>
  
  ```
  
  I hope this helps someone else find the answer they need but I'm also open to suggestions that may improve the result.
  
  
  ---
  
  