public function LinkedImportSettings::formAttachField in CRM Core 7
Attach single field.
1 call to LinkedImportSettings::formAttachField()
- LinkedImportSettings::formAttachLinkedImports in modules/
crm_core_data_import/ plugins/ settings/ LinkedImportSettings.inc - Attach relation fields to form.
File
- modules/
crm_core_data_import/ plugins/ settings/ LinkedImportSettings.inc, line 129
Class
Code
public function formAttachField(&$form, &$form_state, CRMCoreDataImport $importer, $settings, $field) {
$delta = $field['import_id'];
$form['linked_imports']['fields'][$delta] = array(
'#type' => 'fieldset',
'#attributes' => array(
'class' => array(
'settings-fieldset',
),
),
);
$linked_importer = crm_core_data_import_load_importer($field['import_id']);
$mapping_settings = $linked_importer
->getMappingSettings();
$options = array();
foreach ($mapping_settings as $key => $mapping_instance) {
list($entity_type, $entity_bundle, ) = explode(':', $key);
$options[$key] = $entity_bundle;
}
$form['linked_imports']['fields'][$delta]['import_id'] = array(
'#type' => 'value',
'#value' => $field['import_id'],
);
$form['linked_imports']['fields'][$delta]['source'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => !empty($form_state['values']['linked_imports']['fields'][$delta]['source']) ? $form_state['values']['linked_imports']['fields'][$delta]['source'] : FALSE,
);
$form['linked_imports']['fields'][$delta]['label'] = array(
'#type' => 'item',
'#markup' => 'with key',
);
$form['linked_imports']['fields'][$delta]['destination'] = array(
'#type' => 'select',
'#options' => $importer
->getSourceFields(),
'#default_value' => !empty($form_state['values']['linked_imports']['fields'][$delta]['destination']) ? $form_state['values']['linked_imports']['fields'][$delta]['destination'] : FALSE,
);
$form['linked_imports']['fields'][$delta]['remove_field'] = array(
'#type' => 'button',
'#value' => t('Remove'),
'#name' => drupal_html_id('relations-settings-remove-button-' . $delta),
'#ajax' => array(
'callback' => '_crm_core_data_import_relations_callback',
'method' => 'replace',
'wrapper' => 'relations-form-fields-wrapper',
),
);
}