public function ReferencesImportSettingsBase::formAttachReferences in CRM Core 7
Attach reference fields to form.
1 call to ReferencesImportSettingsBase::formAttachReferences()
- ReferencesImportSettingsBase::configForm in modules/
crm_core_data_import/ plugins/ settings/ ReferencesImportSettingsBase.inc - Configuration form for settings plugin.
File
- modules/
crm_core_data_import/ plugins/ settings/ ReferencesImportSettingsBase.inc, line 87 - Base references settings handler for CRM Core Data Import.
Class
- ReferencesImportSettingsBase
- @file Base references settings handler for CRM Core Data Import.
Code
public function formAttachReferences(&$form, &$form_state, $settings) {
$triggering_element = !empty($form_state['triggering_element']) ? $form_state['triggering_element'] : FALSE;
if ($triggering_element['#id'] == 'add-reference-button' && !empty($form_state['values']['references']['reference_type'])) {
$form_state['values']['references']['fields'][]['reference_type'] = $form_state['values']['references']['reference_type'];
}
if (!empty($triggering_element['#parents'][3]) && $triggering_element['#parents'][3] == 'remove_field' && $triggering_element['#parents'][0] == 'references') {
$field_key = $triggering_element['#parents'][2];
unset($form_state['values']['references']['fields'][$field_key]);
}
if (!empty($form_state['values']['references']['fields'])) {
foreach ($form_state['values']['references']['fields'] as $delta => $field) {
list($entity_type, $bundle, $entity_delta, $field_name) = explode(':', $field['reference_type']);
$this
->formAttachFieldReference($form, $form_state, $settings, $entity_type, $bundle, $field_name, $delta, $entity_delta);
}
}
}