You are here

function theme_salesforce_fieldmap_form_table in Salesforce Suite 7.3

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

1 theme call to theme_salesforce_fieldmap_form_table()
salesforce_mapping_form in modules/salesforce_mapping/includes/salesforce_mapping.admin.inc
Return a form for a Salesforce mapping entity.

File

modules/salesforce_mapping/includes/salesforce_mapping.admin.inc, line 506
Configuration page for creating and modifying a mapping.

Code

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

  // Build the rows array.
  $columns = isset($elements['#columns']) ? $elements['#columns'] : (isset($elements['#header']) ? array_keys($elements['#header']) : array());
  $rows = array();
  foreach (element_children($elements) as $child_key) {
    $child =& $elements[$child_key];
    $data = array();
    $row_columns = empty($columns) ? element_children($child) : $columns;
    foreach ($row_columns as $column) {
      if (isset($child[$column])) {
        $cell = array(
          'data' => drupal_render($child[$column]),
        );
        if (isset($child[$column]['#attributes'])) {
          foreach ($child[$column]['#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($child['#attributes'])) {
      foreach ($child['#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);
}