I am dynamically rendering a table in a Drupal 8 module. While creating my renderable array I noticed that I can define my table as a '#theme' => 'table'
or as '#type' => 'table'
.
$variables['test_table'] = [
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => array('class'=>array('my-table')),
'#header_columns' => 4,
];
vs:
$variables['test_table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => array('class'=>array('my-table')),
'#header_columns' => 4,
];
Both of these options seem to output the same thing.
My question is this: Why can I use either '#theme' => 'table'
or '#type' => 'table'
when defining a table renderable array and is there any difference between how Drupal will render these differently.