I am struggling to add multiple links to the same table cell, my current code looks like:
use Drupal\Core\Link; $row = [ 'data' => Link::createFromRoute(...), 'class' => 'middle', ]; $row = [ 'data' => Link::createFromRoute(...), 'class' => 'middle', ]; $rows = ['data' => $row, 'no_striping' => TRUE]; return [ '#theme' => 'table', '#header' => [..], '#rows' => $rows, ];
I've cut down the code to the relevant parts each element of the
$row variable is a new cell and each element of the
$rows variable is a new row. I need to use the data attribute as I have additional attributes on the cell.
At present this works perfectly fine, but my links are rendered in separate cells and I would like them rendered in the same cell. If I just to concatenate the 2
Link::createFromRoute I get the following error:
Recoverable fatal error: Object of class Drupal\Core\Link could not be converted to string
I've tried using the
toString() and the
toRenderable() functions and neither work as I want. Surely it can't be that hard?