I'm trying to add row ID's for a custom table I implemented via a custom module. But when I append an ID to the '#attributes'
array it becomes the table ID, not the row ID. How can I define IDs for rows?
This is what I have so far:
$form['table'] = [
'#type' => 'table',
'#header' => $header_table,
'#rows' => $rows,
'#attributes'=> ['id' => 'IdforRow'],
'#empty' => t('No Data found'),
'#prefix' => '<b>Total Tenders : '.@$count.'</b><br>',
'#suffix' => '',
];
$row = array('data' => 'some data'); $rows[] = array('data' => $row, 'class' => 'some class'); );
Or maybe the following one.$row = array('data' => 'some data'); $rows[] = array('data' => $row, 'class' => array('some class'));
See also drupal.org/forum/support/post-installation/2016-04-21/….foreach ($vars['rows'] as $key => $row) { $vars['rows'][$key] = array('data' => $row, 'class' => array('myclass')); }