Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
xtfer CreditAttribution: xtfer commentedIs this in the wrong project, should it be for https://drupal.org/project/tablefield?
Comment #2
xtfer CreditAttribution: xtfer commentedComment #3
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedNow the data structure as stored in the database looks like:
The first row is the header.