CloseModalDialogCommand example

'#weight' => -10,
      ];
      $response->addCommand(new HtmlCommand('#editor-media-dialog-form', $form));
    }
    else {
      // Only send back the relevant values.       $values = [
        'hasCaption' => $form_state->getValue('hasCaption'),
        'attributes' => $form_state->getValue('attributes'),
      ];
      $response->addCommand(new EditorDialogSave($values));
      $response->addCommand(new CloseModalDialogCommand());
    }

    return $response;
  }

  /** * Gets the default value for the view mode form element. * * @param array $view_mode_options * The array of options for the view mode form element. * @param \Drupal\filter\Plugin\FilterInterface $media_embed_filter * The media embed filter. * @param string $media_element_view_mode_attribute * The data-view-mode attribute on the <drupal-media> element. * * @return string|null * The default value for the view mode form element. */
if ($form_state->getErrors()) {
      unset($form['#prefix']$form['#suffix']);
      $form['status_messages'] = [
        '#type' => 'status_messages',
        '#weight' => -10,
      ];
      $response->addCommand(new HtmlCommand('#editor-link-dialog-form', $form));
    }
    else {
      $response->addCommand(new EditorDialogSave($form_state->getValues()));
      $response->addCommand(new CloseModalDialogCommand());
    }

    return $response;
  }

}

      $form_state->set('url', $form_url);
      $response = $this->ajaxFormWrapper($form_class$form_state);
    }
    elseif (!$form_state->get('ajax')) {
      // if nothing on the stack, non-js forms just go back to the main view editor.       $display_id = $form_state->get('display_id');
      return new RedirectResponse(Url::fromRoute('entity.view.edit_display_form', ['view' => $view->id(), 'display_id' => $display_id]['absolute' => TRUE])->toString());
    }
    else {
      $response = new AjaxResponse();
      $response->addCommand(new CloseModalDialogCommand());
      $response->addCommand(new ShowButtonsCommand(!empty($view->changed)));
      $response->addCommand(new TriggerPreviewCommand());
      if ($page_title = $form_state->get('page_title')) {
        $response->addCommand(new ReplaceTitleCommand($page_title));
      }
    }
    // If this form was for view-wide changes, there's no need to regenerate     // the display section of the form.     if ($display_id !== '') {
      \Drupal::entityTypeManager()->getFormObject('view', 'edit')->rebuildCurrentTab($view$response$display_id);
    }

    
'title' => 'Title',
        'modal' => TRUE,
      ],
    ];
    $this->assertEquals($expected$command->render());
  }

  /** * @covers \Drupal\Core\Ajax\CloseModalDialogCommand */
  public function testCloseModalDialogCommand() {
    $command = new CloseModalDialogCommand();
    $expected = [
      'command' => 'closeDialog',
      'selector' => '#drupal-modal',
      'persist' => FALSE,
    ];

    $this->assertEquals($expected$command->render());
  }

  /** * @covers \Drupal\Core\Ajax\CloseDialogCommand */
if ($form_state->getErrors()) {
      unset($form['#prefix']$form['#suffix']);
      $form['status_messages'] = [
        '#type' => 'status_messages',
        '#weight' => -10,
      ];
      $response->addCommand(new HtmlCommand('#editor-image-dialog-form', $form));
    }
    else {
      $response->addCommand(new EditorDialogSave($form_state->getValues()));
      $response->addCommand(new CloseModalDialogCommand());
    }

    return $response;
  }

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