2

I'm trying to set up a front end user profile that will allow the user to use the multi-select field. When I update from the CP, the changes are reflected on the front end, but this isn't working when trying to update from the front end form.

Is there anything I'm missing?

{% set languageOptionsIds = user.providerLanguages %}

<label for="providerLanguages">What languages do you work with?</label>
{% for option in currentUser.providerLanguages.options %}
    <input type="checkbox" id="providerLanguages" name="fields[providerLanguages][]"
    {% if option.selected in languageOptionsIds %}checked{% endif %} value="{{ option.selected }}">{{ option.label }}
    </input>
{% endfor %}
Matt Steele
  • 221
  • 1
  • 6

1 Answers1

3

I believe that you can get the options directly from the 'currentUser' entry, without referring to 'user' separately (they are likely the same thing in this case anyway):

<label for="providerLanguages">What languages do you work with?</label>
{% for option in currentUser.providerLanguages.options %}
    <input type="checkbox" id="providerLanguages" name="fields[providerLanguages][]"
    {% if option.selected %}checked{% endif %} value="{{ option.value }}">
        {{ option.label }}
    </input>
{% endfor %}

The value is also available as 'option.value' instead of 'option.selected'.

Douglas McDonald
  • 13,457
  • 24
  • 57