function theme_front_page_admin_arrange_form in Front Page 8
Same name and namespace in other branches
- 6.2 front_page.admin.inc \theme_front_page_admin_arrange_form()
- 7.2 front_page.admin.inc \theme_front_page_admin_arrange_form()
- 9.1.x front_page.module \theme_front_page_admin_arrange_form()
Returns HTML for the front page arrange form into a table.
@todo Refactor this function, it's a legacy way.
Parameters
array $variables: An associative array containing:
- form: A render element representing the form.
Return value
string Rendered admin form.
1 string reference to 'theme_front_page_admin_arrange_form'
- front_page_theme in ./
front_page.module - Implements hook_theme().
File
- ./
front_page.module, line 133 - This module allows the site admin to set advanced front page settings.
Code
function theme_front_page_admin_arrange_form($variables) {
$form = $variables['form'];
// Enable the drag handles.
drupal_attach_tabledrag($form['roles'], [
'table_id' => 'front-page-arrange',
'action' => 'order',
'relationship' => 'sibling',
'group' => 'front-page-weight',
]);
$header = [
t('Role'),
t('Mode'),
t('Preview'),
t('Enabled'),
t('Weight'),
];
$rows = [];
$renderer = \Drupal::service('renderer');
foreach (Element::children($form['roles']) as $rid) {
$element =& $form['roles'][$rid];
// Add special classes to be used for tabledrag.js.
$element['weight']['#attributes']['class'] = [
'front-page-weight',
];
$row = [];
$row[] = $renderer
->render($element['title'], FALSE);
$row[] = $renderer
->render($element['mode'], FALSE);
$row[] = $renderer
->render($element['preview'], FALSE);
$row[] = $renderer
->render($element['enabled'], FALSE);
$row[] = $renderer
->render($element['weight'], FALSE);
$row = array_merge([
'data' => $row,
], $element['#attributes']);
$row['class'][] = 'draggable';
$rows[] = $row;
}
$output = '';
if (empty($rows)) {
$rows[] = [
[
'data' => 'no roles',
'colspan' => '5',
],
];
}
$front_page_arrange = [
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'attributes' => [
'id' => 'front-page-arrange',
],
];
$output .= $renderer
->render($front_page_arrange);
foreach (Element::children($form) as $key) {
if (!empty($form[$key])) {
$output .= \Drupal::service('renderer')
->render($form[$key]);
}
}
return $output;
}