theme_table supports cells having a 'header' key along-side a 'data' key to designate that the cell is a header cell. Trying this with table field, however, causes the array containing the 'header' and 'data' fields to be wrapped in another array, with a key of data.

For example:

BEFORE Table Field Processing

$table['rows'] = array(
  array(
     array(
       'data' => t('First header on the first row'),
       'header' => TRUE,
     ),

     t('First value on the first row'),
  ),

  array(
     array(
       'data' => t('First header on the second row'),
       'header' => TRUE,
     ),

     t('First value on the second row'),
  ),
);

AFTER Table Field Processing

$table['#rows'] = array(
  0 => array(
     'data' => array(
       0 => array(
         'data' => array(
           'data' => t('First header on the first row'),
           'header' => TRUE,
         ),

        1 => array(
          'data' => t('First value on the first row'),
     ),
  ),
  1 => array(
     'data' => array(
       0 => array(
         'data' => array(
           'data' => t('First header on the second row'),
           'header' => TRUE,
         ),

        1 => array(
          'data' => t('First value on the second row'),
     ),
  ),
);

Comments

xtfer’s picture

Is this in the wrong project, should it be for https://drupal.org/project/tablefield?

xtfer’s picture

Project: Table Element » TableField
Version: 7.x-1.0-beta1 » 7.x-2.x-dev
lolandese’s picture

Status: Active » Fixed

Now the data structure as stored in the database looks like:
Data structure

The first row is the header.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.