You are here

function _crm_core_data_import_attach_entity_form in CRM Core 7

Entity types and bundles.

1 call to _crm_core_data_import_attach_entity_form()
crm_core_data_import_field_mapping in modules/crm_core_data_import/crm_core_data_import.admin.inc
Page callback for field mapping page.

File

modules/crm_core_data_import/crm_core_data_import.admin.inc, line 609
Configuration pages for CRM Core Data Import.

Code

function _crm_core_data_import_attach_entity_form(&$form, &$form_state) {
  ctools_include('plugins');
  $plugins = ctools_get_plugins('crm_core_data_import', 'crm_core_data_import_destination');
  $entity_plugins = array();
  $entity_bundles = array();
  foreach ($plugins as $id => $plugin) {
    $entity_plugins[$id] = $plugin['label'];
  }
  $form['entity_form'] = array(
    '#type' => 'container',
    '#prefix' => '<div id="entity-form-fieldset-wrapper">',
    '#suffix' => '</div>',
  );
  $form['entity_form']['entity_type'] = array(
    '#type' => 'select',
    '#title' => t('Add an:'),
    '#empty_option' => t('- Entity type -'),
    '#options' => $entity_plugins,
    '#ajax' => array(
      'callback' => '_crm_core_data_import_entity_form_entity_type_callback',
      'wrapper' => 'entity-form-fieldset-wrapper',
    ),
  );
  if (!empty($form_state['values']['entity_form']['entity_type'])) {
    $destination = crm_core_data_import_load_plugin_instance('crm_core_data_import_destination', $form_state['values']['entity_form']['entity_type']);
    $entity_bundles = $destination
      ->getBundles();
  }
  $form['entity_form']['entity_bundle'] = array(
    '#type' => 'select',
    '#title' => t('of type:'),
    '#options' => $entity_bundles,
  );
  $form['entity_form']['add_entity'] = array(
    '#type' => 'button',
    '#id' => 'add-entity-button',
    '#value' => t('Add'),
    '#ajax' => array(
      'callback' => '_crm_core_data_import_entity_form_add_entity_callback',
      'method' => 'replace',
      'wrapper' => 'mapping-fieldset-wrapper',
    ),
  );
}