You are here

function template_preprocess_vefl_views_exposed_form in Views exposed form layout 8

Same name and namespace in other branches
  1. 8.3 vefl.module \template_preprocess_vefl_views_exposed_form()
  2. 8.2 vefl.module \template_preprocess_vefl_views_exposed_form()

A theme preprocess function for views_exposed_form.

Adds $region_widgets array with separated by regions widgets.

1 string reference to 'template_preprocess_vefl_views_exposed_form'
vefl_theme_registry_alter in ./vefl.module
Implements hook_theme_registry_alter().

File

./vefl.module, line 36
Module file for vefl.

Code

function template_preprocess_vefl_views_exposed_form(&$variables) {
  $form = $variables['form'];
  $configuration = $form['#vefl_configuration'];
  $regions = [];
  foreach ($configuration['regions'] as $region_name => $field_names) {
    $regions[$region_name] = [];
    foreach ($field_names as $field_name) {
      if (!empty($form['actions'][$field_name])) {
        $regions[$region_name][$field_name] = $form['actions'][$field_name];
        $regions[$region_name][$field_name]['#weight'] = $form['actions']['#weight'];
      }
      elseif (!empty($form[$field_name])) {
        $regions[$region_name][$field_name] = $form[$field_name];
      }
    }
  }
  $layout = Layout::layoutPluginManager()
    ->createInstance($configuration['layout']['id'], $configuration['layout']['settings']);
  $built = $layout
    ->build($regions);
  $variables['form'] = $built;
}