Setting a disabled value for a checkbox field via API wipes enabled values
Not quite sure what the use case would be but this was brought to my attention on mattermost and I replicated on a fresh buildkit install 5.19.alpha1.
- Create a custom checkbox field and set a couple of option values (say, 'option1','option2','option3')
- Disable 'option3'
- Create values including the disabled one for your custom field via api e.g.
$result = civicrm_api3('Contact', 'create', [ 'id' => 202, 'custom_14' => ['option1','option2','option3'], ]);
- Now retrieve the values set here and/or view the contact and you'll see it's been set to something like this:
and what's stored seems to be keys instead of valid values:
Even though two of the values we tried to set are valid.
I would expect this to behave instead like the multi-select field does. For a multi-select field an API create including a disabled value will simply accept the disabled value and store it, but it won't display on the contact record. The active values still display as expected.