}
static function buildOption($field, &$options) {
+ // Fixme - adding anything but options to the $options array is a bad idea
+ // What if an option had the key 'attributes'?
$options['attributes'] = array(
'label' => $field['label'],
'data_type' => $field['data_type'],
$flip = !empty($params['flip']);
// Custom fields are not in the schema
- if (strpos($fieldName, 'custom') === 0) {
+ if (strpos($fieldName, 'custom') === 0 && is_numeric($fieldName[7])) {
$dao = new CRM_Core_DAO_CustomField;
$dao->id = (int) substr($fieldName, 7);
$dao->find(TRUE);
$dao->free();
$output = array();
CRM_Core_BAO_CustomField::buildOption($customField, $output);
+ // @see FIXME note in CRM_Core_BAO_CustomField::buildOption()
+ unset($output['attributes']);
return $flip ? array_flip($output) : $output;
}
$result = civicrm_api('customGroup', 'create', $api_params);
$this->assertAPISuccess($result);
- // Create a Group for testing.
+ // Add a custom field to the above field group.
+ $api_params = array(
+ 'version' => 3,
+ 'debug' => 1,
+ 'custom_group_id' => $result['id'],
+ 'label' => $custom_group_name,
+ 'html_type' => 'Select',
+ 'data_type' => 'String',
+ 'is_active' => TRUE,
+ 'option_values' => array(array(
+ 'label' => 'Foo',
+ 'value' => 'foo',
+ 'is_active' => 1,
+ 'weight' => 0,
+ )),
+ );
+ $result = civicrm_api('custom_field', 'create', $api_params);
+ $this->assertAPISuccess($result);
+ $customFieldId = $result['id'];
+
+ // Create a Contact Group for testing.
$group_name = md5(microtime());
$api_params = array(
'version' => 3,
'sample' => array('en_US' => 'English (United States)'),
'max' => 250,
),
+ array(
+ 'fieldName' => "custom_$customFieldId",
+ 'sample' => array('foo' => 'Foo'),
+ 'max' => 1,
+ ),
),
'CRM_Batch_DAO_Batch' => array(
array(