function template_preprocess_views_ui_build_group_filter_form
template_preprocess_views_ui_build_group_filter_form(&$variables)
Prepares variables for Views UI build group filter form templates.
Default template: views-ui-build-group-filter-form.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 78
- Preprocessors and theme functions for the Views UI.
Code
function template_preprocess_views_ui_build_group_filter_form(&$variables) { $form = $variables['form']; // Prepare table of options. $header = array( t('Default'), t('Weight'), t('Label'), t('Operator'), t('Value'), t('Operations'), ); // Prepare default selectors. $form_state = new FormState(); $form['default_group'] = Radios::processRadios($form['default_group'], $form_state, $form); $form['default_group_multiple'] = Checkboxes::processCheckboxes($form['default_group_multiple'], $form_state, $form); $form['default_group']['All']['#title'] = ''; $rows[] = array( ['data' => $form['default_group']['All']], '', array( 'data' => \Drupal::config('views.settings')->get('ui.exposed_filter_any_label') == 'old_any' ? t('<Any>') : t('- Any -'), 'colspan' => 4, 'class' => array('class' => 'any-default-radios-row'), ), ); // Remove the 'All' default_group form element because it's added to the // table row. unset($variables['form']['default_group']['All']); foreach (Element::children($form['group_items']) as $group_id) { $form['group_items'][$group_id]['value']['#title'] = ''; $default = [ $form['default_group'][$group_id], $form['default_group_multiple'][$group_id], ]; // Remove these fields from the form since they are moved into the table. unset($variables['form']['default_group'][$group_id]); unset($variables['form']['default_group_multiple'][$group_id]); $link = [ '#type' => 'link', '#url' => Url::fromRoute('<none>', [], [ 'attributes' => [ 'id' => 'views-remove-link-' . $group_id, 'class' => [ 'views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link', ], 'alt' => t('Remove this item'), 'title' => t('Remove this item'), ], ]), '#title' => SafeMarkup::format('<span>@text</span>', ['@text' => t('Remove')]), ]; $remove = [$form['group_items'][$group_id]['remove'], $link]; $data = array( 'default' => ['data' => $default], 'weight' => ['data' => $form['group_items'][$group_id]['weight']], 'title' => ['data' => $form['group_items'][$group_id]['title']], 'operator' => ['data' => $form['group_items'][$group_id]['operator']], 'value' => ['data' => $form['group_items'][$group_id]['value']], 'remove' => ['data' => $remove], ); $rows[] = array('data' => $data, 'id' => 'views-row-' . $group_id, 'class' => array('draggable')); } $variables['table'] = array( '#type' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => array( 'class' => array('views-filter-groups'), 'id' => 'views-filter-groups', ), '#tabledrag' => array( array( 'action' => 'order', 'relationship' => 'sibling', 'group' => 'weight', ) ), ); // Hide fields used in table. unset($variables['form']['group_items']); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!views_ui!views_ui.theme.inc/function/template_preprocess_views_ui_build_group_filter_form/8.1.x