protected function WebformEditorialController::buildTable in Webform 8.5
Build a reusable and styled table for inputs, outputs, and publications.
Parameters
string $title: The table's title.
array $header: The table's header.
array $rows: The table's rows.
string $title_tag: The header tag for title.
bool $hr: Append horizontal rule.
Return value
array A renderable array representing a table with title.
6 calls to WebformEditorialController::buildTable()
- WebformEditorialController::drush in modules/
webform_editorial/ src/ Controller/ WebformEditorialController.php - Returns webform drush.
- WebformEditorialController::elements in modules/
webform_editorial/ src/ Controller/ WebformEditorialController.php - Returns webform elements editorial.
- WebformEditorialController::help in modules/
webform_editorial/ src/ Controller/ WebformEditorialController.php - Returns webform help editorial.
- WebformEditorialController::libraries in modules/
webform_editorial/ src/ Controller/ WebformEditorialController.php - Returns webform libraries.
- WebformEditorialController::schema in modules/
webform_editorial/ src/ Controller/ WebformEditorialController.php - Returns webform schema.
File
- modules/
webform_editorial/ src/ Controller/ WebformEditorialController.php, line 479
Class
- WebformEditorialController
- Provides route responses for webform editorial.
Namespace
Drupal\webform_editorial\ControllerCode
protected function buildTable($title, array $header, array $rows, $title_tag = 'h1', $hr = TRUE) {
// Add style and alignment to header.
foreach ($header as &$column) {
$column['style'] = 'background-color: #ccc';
$column['valign'] = 'top';
$column['align'] = 'left';
}
// Add style and alignment to rows.
foreach ($rows as &$row) {
foreach ($row['data'] as &$column) {
if (isset($column['data'])) {
$column['data'] = [
'#markup' => $column['data'],
'#allowed_tags' => Xss::getAdminTagList(),
];
}
}
$row['valign'] = 'top';
$row['align'] = 'left';
}
return [
'title' => [
'#prefix' => "<{$title_tag}>",
'#suffix' => "</{$title_tag}>",
'#markup' => $title,
],
'description' => [],
'table' => [
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => [
'border' => 1,
'cellspacing' => 0,
'cellpadding' => 5,
'width' => '950',
],
],
'#suffix' => $hr ? '<br/><hr/>' : '',
];
}