resetForm example

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

  /** * {@inheritdoc} */
  public function exposedFormSubmit(&$form, FormStateInterface $form_state, &$exclude) {
    if (!$form_state->isValueEmpty('op') && $form_state->getValue('op') == $this->options['reset_button_label']) {
      $this->resetForm($form$form_state);
    }
    if ($pager_plugin = $form_state->get('pager_plugin')) {
      $pager_plugin->exposedFormSubmit($form$form_state$exclude);
      $exclude[] = 'pager_plugin';
    }
  }

  /** * Resets all the states of the exposed form. * * This method is called when the "Reset" button is triggered. Clears * user inputs, stored session, and the form state. * * @param array $form * An associative array containing the structure of the form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */
Home | Imprint | This part of the site doesn't use cookies.