I am attempting to add some user fields based on the extend-user sprinkle: https://github.com/userfrosting/extend-user. The users in this site are all alumni of a school. One of the fields I want to add is a multiselect field to indicate any areas of expertise an alumni member might have. There are a whole slew of options and users should be able to have any number of them
I tried to add a simple select field with the “multiple” option specified to my template:
{% for area in job_areas %}
<option value="{{area}}" {% if (area == user.alum_job_area) %}selected{% endif %}>{{area}}
{% endfor %}
(“job_areas” is the list of options, defined in my controller and passed to this template.)
It displays fine in the modal window, and selected items are added to the field area as individual boxes. However, on submission, only the last one in the list is persisted to the database. I looked at the submitted form data in my browser, and these items shows up as several separate entries all with the key “alum_job_areas” – my guess is the earlier ones are overwritten in succession and so all that remains is the last one in the list.
The method that is called after submission is updateInfo in side of the native UserController, since I am extending that class.
Is there a way to ensure all the values are saved to the database? It shouldn’t be a SQL issue because this field has the “TEXT” type and so there’s not a character limit.