You are here

function theme_redhen_dedupe_form_table in RedHen CRM 7

Themes the field associations on a fieldmap edit form into a table.

1 theme call to theme_redhen_dedupe_form_table()
redhen_dedupe_merge_form in modules/redhen_dedupe/includes/redhen_dedupe.form.inc
Form to select the master contact.

File

modules/redhen_dedupe/includes/redhen_dedupe.form.inc, line 239
Forms for creating, editing, and deleting contacts.

Code

function theme_redhen_dedupe_form_table($variables) {
  $elements = $variables['elements'];

  // Build the rows array.
  $rows = array();
  foreach (element_children($elements) as $item_key) {
    $item =& $elements[$item_key];
    $data = array(
      $item['#title'],
    );
    foreach (element_children($item) as $element) {
      if (isset($item['#options']) && $item['#options'][$element] === REDHEN_DEDUPE_NOT_APPLICABLE) {
        $cell_data = t('Field not applicable to this bundle');
      }
      else {
        $cell_data = drupal_render($item[$element]);
      }
      $cell = array(
        'data' => $cell_data,
      );
      if (isset($item[$element]['#attributes'])) {
        foreach ($item[$element]['#attributes'] as $key => $value) {
          $cell[$key] = $key == 'id' ? is_array($value) ? array(
            $value[0] . '-cell',
          ) : $value . '-cell' : $value;
        }
      }
      $data[] = $cell;
    }
    $row = array(
      'data' => $data,
    );
    if (isset($item_key['#attributes'])) {
      foreach ($item_key['#attributes'] as $key => $value) {
        $row[$key] = $value;
      }
    }
    $rows[] = $row;
  }
  $config = array(
    'rows' => $rows,
  );
  if (isset($elements['#header'])) {
    $config['header'] = $elements['#header'];
  }
  if (isset($elements['#attributes']) && is_array($elements['#attributes'])) {
    $config['attributes'] = $elements['#attributes'];
  }
  return theme('table', $config);
}