State/Province Multi-select fails to save values
Overview
A Custom Field of type State/Province Multi-select fails to save values when attached to an Event and "Is this Field Searchable?" is set to false
. Reproduced on WPMaster and DMaster demo sites for a CiviEvent. I haven't checked if this is exclusive to Events, but can see the solution and will open a PR in due course.
Reproduction steps
- Create a set of Custom Fields and attach to to "Event"
- Add a field of data type "State/Province" and field type "Select State/Province"
- Enable "Multi-Select" and disable "Is this Field Searchable?"
- Visit a "Configure Event" page and select some "State/Province" values
- Submit the form to save the event - State/Province" values are saved
- Submit the form again to save the event - State/Province" values are lost
Current behaviour
Following the above procedure (line refs are for 5.26.2) throws the following warnings:
[02-Jul-2020 12:59:29 Europe/London] PHP Warning: explode() expects parameter 2 to be string, array given in /path/to/CRM/Core/BAO/CustomGroup.php on line 1383
[02-Jul-2020 12:59:29 Europe/London] PHP Warning: Invalid argument supplied for foreach() in /path/to/CRM/Core/BAO/CustomGroup.php on line 1384
The WPMaster and DMaster logs will show similar entries.
Expected behaviour
The incoming data should be parsed in the same way that this commit implements. Doing so fixes the problem.