Trying to show selected categories in a multi select form input
When you do currentUser.occupation.all() your selected variable is an objet so your conditional {% if category.id == selected %} will never pass as you are checking if category.id equals an object.

For this to work, first get the ids of the currentUser occupations:

{% set selected = currentUser.occupation.ids() %}

Which would return an array of ids (key/value pairs) then you compare doing:

{% if category.id in selected|values %}

So in full:

    &lt;select multiple name="fields[occupation][]" class="selectpicker" &gt;
        {% for category in categories %}        
        {% set selected = currentUser.occupation.ids() %}
          &lt;option value="{{ category.id }}" {% if category.id in selected|values %} selected{% endif %} &gt; {{ category.title }} &lt;/option&gt;
        {% endfor %}
    &lt;/select&gt;