You are here

function _crm_core_data_import_theme_mapping_form in CRM Core 7

Helper to theme mapping form.

4 calls to _crm_core_data_import_theme_mapping_form()
theme_crm_core_data_import_field_mapping in modules/crm_core_data_import/crm_core_data_import.module
Theme implementation for mapping form.
_crm_core_data_import_add_another_field_callback in modules/crm_core_data_import/crm_core_data_import.admin.inc
Callback for add another field button.
_crm_core_data_import_entity_form_add_entity_callback in modules/crm_core_data_import/crm_core_data_import.admin.inc
Callback for entity fieldset submit.
_crm_core_data_import_entity_type_action_callback in modules/crm_core_data_import/crm_core_data_import.admin.inc
Callback for actions for entity bundle.

File

modules/crm_core_data_import/crm_core_data_import.module, line 480
Provides basic functionality for a CRM Core Data Import.

Code

function _crm_core_data_import_theme_mapping_form(&$form) {
  $header = array(
    t('Source field'),
    t('Destination field'),
    t('Default value'),
    t('Remove field'),
  );
  if (!empty($form['mapping'])) {

    // Loop over all mapping fields and render they as table.
    foreach ($form['mapping'] as $key => $mapping_item) {
      if (is_array($mapping_item) && !empty($mapping_item['fields'])) {
        $rows = array();
        foreach (element_children($mapping_item['fields'], TRUE) as $id) {
          $field =& $mapping_item['fields'][$id];
          $row = array(
            'data' => array(),
          );
          if ($id === 'primary') {
            $row['data'][] = drupal_render($field['source_field_primary']);
            $row['data'][] = drupal_render($field['destination_field_primary']);
            $row['data'][] = '';
            $row['data'][] = '';
          }
          else {
            $row['data'][] = drupal_render($field['source_field']);
            $row['data'][] = drupal_render($field['destination_field']);
            $row['data'][] = drupal_render($field['default_value']);
            $row['data'][] = drupal_render($field['remove_field']);
          }
          $rows[] = $row;
        }
        $form['mapping'][$key]['fields'] = array();
        $form['mapping'][$key]['fields']['#markup'] = theme('table', array(
          'header' => $header,
          'rows' => $rows,
          'attributes' => array(
            'class' => array(
              'mapping-fields-table',
            ),
          ),
        ));
      }
    }
  }
}