function civicrm_entity_reference_field_field_settings_form in CiviCRM Entity 7.2
Implements hook_field_settings_form().
Parameters
$field:
$instance:
$has_data:
File
- modules/
civicrm_entity_reference_field/ civicrm_entity_reference_field.module, line 94 - Provide CiviCRM entity reference field type
Code
function civicrm_entity_reference_field_field_settings_form($field, $instance, $has_data) {
$defaults = field_info_field_settings($field['type']);
$settings = array_merge($defaults, $field['settings']);
$host_entity_type = $instance['entity_type'];
$civicrm_entities = _civicrm_entity_enabled_entities();
$entities = array();
foreach ($civicrm_entities as $drupal_name => $civicrm_name) {
$entities[$civicrm_name] = ucwords(str_replace('_', ' ', $civicrm_name));
}
$form['target_entity_type'] = array(
'#type' => 'select',
'#title' => t('Target Entity Type'),
'#default_value' => $settings['target_entity_type'],
'#description' => t('Target entity type for this reference field.'),
'#options' => $entities,
'#ajax' => array(
'event' => 'change',
'wrapper' => 'target-id-column-wrapper',
'callback' => 'civicrm_entity_reference_field_target_entity_type_ajax_callback',
'method' => 'replace',
),
);
$target_id_column_options = _civicrm_entity_reference_field_get_target_id_column_options($settings['target_entity_type']);
$form['target_id_column'] = array(
'#type' => 'select',
'#title' => t('Target ID Join Column'),
'#default_value' => $settings['target_id_column'],
'#description' => t('The column of the targeted entity type to use to query against'),
'#options' => $target_id_column_options,
'#prefix' => '<div id="target-id-column-wrapper">',
'#suffix' => '</div>',
'#validated' => TRUE,
);
$form['host_source_id'] = array(
'#type' => 'select',
'#title' => t('Host Source Column'),
'#default_value' => $settings['host_source_id'],
'#description' => t('Host Entity property which value is used query target entity table.'),
// want to automate choices for this setting in the future
'#options' => array(
'id' => 'ID',
'loc_block_id' => 'Location Block ID (CiviCRM Event Entity)',
'address_id' => 'Address ID (Location Block Entity)',
'email_id' => 'Email ID (Location Block Entity)',
'phone_id' => 'Phone ID (Location Block Entity)',
'im_id' => 'Instant Messaging ID (Location Block Entity)',
'uf_group_id' => 'UFGroup ID (UFJoin Entity)',
'contact_id' => 'Contact ID (Grant Entity)',
),
);
return $form;
}