Some Multi-Select Custom Fields cannot be saved
Overview
The following Custom Field types cannot be saved in the CiviCRM UI nor via API v3:
- Integer Drop-down Multi-Select
- Number Drop-down Multi-Select
- Money Drop-down Multi-Select
They result in the following errors respectively:
One of parameters (value: *2*4*) is not of the type Timestamp
One of parameters (value: *2*4*) is not of the type Float
One of parameters (value: *2.99*3.99*1.99*) is not of the type Money
(Where the * characters above are actually CRM_Core_DAO::VALUE_SEPARATOR
)
As per this discussion on MatterMost.
Reproduction steps
- Create a Custom Field of type
Integer
,Number
orMoney
- Select the "Multi-Select" checkbox
- Add some values for the Select
Values cannot be saved in the CiviCRM UI nor via API v3, e.g.
$result = civicrm_api3('Contact', 'create', [
'id' => 210,
'contact_type' => "Individual",
'custom_20' => [2, 4],
]);
Current behaviour
Error messages as above.
Expected behaviour
The items in the "serialised array" should be checked for their respective types rather than testing the "serialised array" itself and, if valid, should be saved.
Environment information
Found in CiviCRM 5.34.0 but almost certainly present since 5.27 and likely a result of this PR which introduced the "Multi-Select" checkbox for all Custom Fields of type "Select". Prior to 5.27 Integer
, Number
and Money
did not have a "Multi-Select" option.