Created
May 8, 2022 08:46
-
-
Save manniru/ce6ad2c4c1bfb83282a59cf71e59e2d0 to your computer and use it in GitHub Desktop.
How to render a table in drupal 8 (with html in cells)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use Drupal\Core\Render\Markup; | |
| $rows = [ | |
| [Markup::create('<strong>test 1</strong>'),'test'], | |
| [Markup::create('<s>test 2</s>'), 'test'], | |
| [Markup::create('<div>test 3</div>'), 'test'], | |
| ]; | |
| $header = [ | |
| 'title' => t('Title'), | |
| 'content' => t('Content'), | |
| ]; | |
| $build['table'] = [ | |
| '#type' => 'table', | |
| '#header' => $header, | |
| '#rows' => $rows, | |
| '#empty' => t('No content has been found.'), | |
| ]; | |
| return [ | |
| '#type' => '#markup', | |
| '#markup' => render($build) | |
| ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment