exposedFormAlter example


      $all_exposed = array_merge($exposed_sorts$exposed_filters);

      // Set the access to FALSE if there is no exposed input.       if (!array_intersect_key($all_exposed$this->view->getExposedInput())) {
        $form['actions']['reset']['#access'] = FALSE;
      }
    }

    $pager = $this->view->display_handler->getPlugin('pager');
    if ($pager) {
      $pager->exposedFormAlter($form$form_state);
      $form_state->set('pager_plugin', $pager);
    }
  }

  /** * {@inheritdoc} */
  public function exposedFormValidate(&$form, FormStateInterface $form_state) {
    if ($pager_plugin = $form_state->get('pager_plugin')) {
      $pager_plugin->exposedFormValidate($form$form_state);
    }
  }


    $form['#action'] = $form_action;
    $form['#theme'] = $view->buildThemeFunctions('views_exposed_form');
    $form['#id'] = Html::cleanCssIdentifier('views_exposed_form-' . $view->storage->id() . '-' . $display['id']);
    // Labels are built too late for inline form errors to work, resulting     // in duplicated messages.     $form['#disable_inline_form_errors'] = TRUE;

    /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface $exposed_form_plugin */
    $exposed_form_plugin = $view->display_handler->getPlugin('exposed_form');
    $exposed_form_plugin->exposedFormAlter($form$form_state);

    // Save the form.     $this->exposedFormCache->setForm($view->storage->id()$view->current_display, $form);

    return $form;
  }

  /** * {@inheritdoc} */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    
Home | Imprint | This part of the site doesn't use cookies.