'max_multiple' => 0,
], $params);
$identifier = $params['name'] ?? $params['title'];
- $this->ids['CustomGroup'][$identifier] = CustomGroup::create()->setCheckPermissions(FALSE)->setValues($params)->execute()->first()['id'];
+ $this->ids['CustomGroup'][$identifier] = CustomGroup::create(FALSE)->setValues($params)->execute()->first()['id'];
return $this->ids['CustomGroup'][$identifier];
}
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function createCustomGroupWithFieldOfType($groupParams = [], $customFieldType = 'text', $identifier = NULL) {
- $supported = ['text', 'select', 'date', 'int', 'contact_reference'];
+ $supported = ['text', 'select', 'date', 'int', 'contact_reference', 'radio'];
if (!in_array($customFieldType, $supported, TRUE)) {
throw new CRM_Core_Exception('we have not yet extracted other custom field types from createCustomFieldsOfAllTypes, Use consistent syntax when you do');
}
case 'contact_reference':
$reference = $this->createContactReferenceCustomField($fieldParams)['id'];
return;
+
+ case 'radio':
+ $reference = $this->createIntegerRadioCustomField($fieldParams)['id'];
+ return;
+
}
}
return $this->callAPISuccess('custom_field', 'create', $params)['values'][0];
}
+ /**
+ * Create a custom field of type radio with integer values.
+ *
+ * @param array $params
+ *
+ * @return array
+ */
+ protected function createIntegerRadioCustomField($params): array {
+ $params = array_merge($this->getFieldsValuesByType('Int', 'Radio'), $params);
+ return $this->callAPISuccess('custom_field', 'create', $params)['values'][0];
+ }
+
/**
* Get default field values for the type of field.
*
],
'CheckBox' => [
'label' => 'Pick Color',
- 'html_type' => 'Checkbox',
+ 'html_type' => 'CheckBox',
'data_type' => 'String',
'text_length' => '',
'default_value' => '',
'weight' => 2,
'is_active' => 1,
],
+ [
+ 'label' => 'Red Testing',
+ 'value' => 5,
+ 'weight' => 3,
+ 'is_active' => 1,
+ ],
],
],
],