You are here

protected function YamlFormDialogTrait::redirectForm in YAML Form 8

Handler dialog redirect after form is submitted.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

\Drupal\Core\Url $url: Redirect URL.

Return value

\Drupal\Core\Ajax\AjaxResponse|null An AJAX redirect response or null if redirection is being handled by the $form_state.

3 calls to YamlFormDialogTrait::redirectForm()
YamlFormEntityForm::submitForm in src/YamlFormEntityForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
YamlFormHandlerFormBase::submitForm in src/Form/YamlFormHandlerFormBase.php
Form submission handler.
YamlFormUiElementFormBase::submitForm in modules/yamlform_ui/src/Form/YamlFormUiElementFormBase.php
Form submission handler.

File

src/YamlFormDialogTrait.php, line 95

Class

YamlFormDialogTrait
Trait class form dialogs.

Namespace

Drupal\yamlform

Code

protected function redirectForm(array &$form, FormStateInterface $form_state, Url $url) {
  if ($this
    ->isModalDialog()) {
    $response = new AjaxResponse();
    $response
      ->addCommand(new RedirectCommand($url
      ->toString()));
    return $response;
  }
  else {
    $form_state
      ->setRedirectUrl($url);
    return NULL;
  }
}