+ elseif (
+ // Legacy handling for historical apiv3 behaviour.
+ empty($params['id'])
+ && !empty($params['html_type'])
+ && $params['html_type'] !== 'Text'
+ && empty($params['option_group_id'])
+ && empty($params['option_value'])
+ && in_array($params['data_type'] ?? '', ['String', 'Int', 'Float', 'Money'])) {
+ // Trick the BAO into creating an option group even though no option values exist
+ // because that odd behaviour is locked in via a test.
+ $params['option_value'] = 1;
+ }