function template_preprocess_views_ui_style_plugin_table
Same name in other branches
- 9 core/modules/views_ui/views_ui.theme.inc \template_preprocess_views_ui_style_plugin_table()
- 10 core/modules/views_ui/views_ui.theme.inc \template_preprocess_views_ui_style_plugin_table()
- 11.x core/modules/views_ui/views_ui.theme.inc \template_preprocess_views_ui_style_plugin_table()
Prepares variables for style plugin table templates.
Default template: views-ui-style-plugin-table.html.twig.
Parameters
array $variables: An associative array containing:
- form: A render element representing the form.
File
-
core/
modules/ views_ui/ views_ui.theme.inc, line 397
Code
function template_preprocess_views_ui_style_plugin_table(&$variables) {
$form = $variables['form'];
$header = [
t('Field'),
t('Column'),
t('Align'),
t('Separator'),
[
'data' => t('Sortable'),
'align' => 'center',
],
[
'data' => t('Default order'),
'align' => 'center',
],
[
'data' => t('Default sort'),
'align' => 'center',
],
[
'data' => t('Hide empty column'),
'align' => 'center',
],
[
'data' => t('Responsive'),
'align' => 'center',
],
];
$rows = [];
foreach (Element::children($form['columns']) as $id) {
$row = [];
$row[]['data'] = $form['info'][$id]['name'];
$row[]['data'] = $form['columns'][$id];
$row[]['data'] = $form['info'][$id]['align'];
$row[]['data'] = $form['info'][$id]['separator'];
if (!empty($form['info'][$id]['sortable'])) {
$row[] = [
'data' => $form['info'][$id]['sortable'],
'align' => 'center',
];
$row[] = [
'data' => $form['info'][$id]['default_sort_order'],
'align' => 'center',
];
$row[] = [
'data' => $form['default'][$id],
'align' => 'center',
];
}
else {
$row[] = '';
$row[] = '';
$row[] = '';
}
$row[] = [
'data' => $form['info'][$id]['empty_column'],
'align' => 'center',
];
$row[] = [
'data' => $form['info'][$id]['responsive'],
'align' => 'center',
];
$rows[] = $row;
}
// Add the special 'None' row.
$rows[] = [
[
'data' => t('None'),
'colspan' => 6,
],
[
'align' => 'center',
'data' => $form['default'][-1],
],
[
'colspan' => 2,
],
];
// Unset elements from the form array that are used to build the table so that
// they are not rendered twice.
unset($form['default']);
unset($form['info']);
unset($form['columns']);
$variables['table'] = [
'#type' => 'table',
'#theme' => 'table__views_ui_style_plugin_table',
'#header' => $header,
'#rows' => $rows,
];
$variables['form'] = $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.