public function LinkedImportSettings::formAttachLinkedImports in CRM Core 7
Attach relation fields to form.
1 call to LinkedImportSettings::formAttachLinkedImports()
- LinkedImportSettings::configForm in modules/
crm_core_data_import/ plugins/ settings/ LinkedImportSettings.inc - Configuration form for settings plugin.
File
- modules/
crm_core_data_import/ plugins/ settings/ LinkedImportSettings.inc, line 106
Class
Code
public function formAttachLinkedImports(&$form, &$form_state, $settings, CRMCoreDataImport $importer) {
$triggering_element = !empty($form_state['triggering_element']) ? $form_state['triggering_element'] : FALSE;
if ($triggering_element['#name'] == 'add-import-button' && !empty($form_state['values']['linked_imports']['import'])) {
$import_id = $form_state['values']['linked_imports']['import'];
$form_state['values']['linked_imports']['fields'][$import_id] = array(
'import_id' => $import_id,
);
}
if (!empty($triggering_element['#parents'][3]) && $triggering_element['#parents'][3] == 'remove_field' && $triggering_element['#parents'][0] == 'linked_imports') {
$field_key = $triggering_element['#parents'][2];
unset($form_state['values']['linked_imports']['fields'][$field_key]);
}
if (!empty($form_state['values']['linked_imports']['fields'])) {
foreach ($form_state['values']['linked_imports']['fields'] as $delta => $field) {
$this
->formAttachField($form, $form_state, $importer, $settings, $field);
}
}
}