- $baoName = _civicrm_api3_get_BAO($apiRequest['entity']);
- $options = $baoName::buildOptions($fieldName, $context, $apiRequest['params']);
+ // Legacy support for campaign_id fields which used to have a pseudoconstant
+ if ($fieldName === 'campaign_id') {
+ $campaignParams = [
+ 'select' => ['id', 'name', 'title'],
+ 'options' => ['limit' => 0],
+ ];
+ if ($context === 'match' || $context === 'create') {
+ $campaignParams['is_active'] = 1;
+ }
+ $labelField = $context === 'validate' ? 'name' : 'title';
+ $keyField = $context === 'match' ? 'name' : 'id';
+ $options = array_column(civicrm_api3('Campaign', 'get', $campaignParams)['values'], $labelField, $keyField);
+ }
+ else {
+ $baoName = _civicrm_api3_get_BAO($apiRequest['entity']);
+ $options = $baoName::buildOptions($fieldName, $context, $apiRequest['params']);
+ }