getFormState example

$response->addCommand(new PrependCommand(NULL, $status_messages));
      $event->allowCustomResponseCode();
      $event->setResponse($response);
      return;
    }

    // Extract the form AJAX exception (it may have been passed to another     // exception before reaching here).     if ($exception = $this->getFormAjaxException($exception)) {
      $request = $event->getRequest();
      $form = $exception->getForm();
      $form_state = $exception->getFormState();

      // Set the build ID from the request as the old build ID on the form.       $form['#build_id_old'] = $request->request->get('form_build_id');

      try {
        $response = $this->formAjaxResponseBuilder->buildResponse($request$form$form_state[]);

        // Since this response is being set in place of an exception, explicitly         // mark this as a 200 status.         $response->setStatusCode(200);
        $event->allowCustomResponseCode();
        
->set('type', $this->type)
      ->set('id', $this->id)
      ->disableRedirect()
      ->addBuildInfo('callback_object', $this);
  }

  /** * {@inheritdoc} */
  public function getForm(ViewEntityInterface $view$display_id$js) {
    /** @var \Drupal\Core\Form\FormStateInterface $form_state */
    $form_state = $this->getFormState($view$display_id$js);
    $view = $form_state->get('view');
    $form_key = $form_state->get('form_key');

    // @todo Remove the need for this.     \Drupal::moduleHandler()->loadInclude('views_ui', 'inc', 'admin');

    // Reset the cache of IDs. Drupal rather aggressively prevents ID     // duplication but this causes it to remember IDs that are no longer even     // being used.     Html::resetSeenIds();

    
public function getFormKey() {
    return 'display';
  }

  /** * {@inheritdoc} * * @todo Remove this and switch all usage of $form_state->get('section') to * $form_state->get('type'). */
  public function getFormState(ViewEntityInterface $view$display_id$js) {
    $form_state = parent::getFormState($view$display_id$js);
    $form_state->set('section', $this->type);
    return $form_state;
  }

  /** * {@inheritdoc} */
  public function getForm(ViewEntityInterface $view$display_id$js$type = NULL) {
    $this->setType($type);
    return parent::getForm($view$display_id$js);
  }

  
Home | Imprint | This part of the site doesn't use cookies.