You are here

protected function WebformDialogFormTrait::buildDialogConfirmForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Form/WebformDialogFormTrait.php \Drupal\webform\Form\WebformDialogFormTrait::buildDialogConfirmForm()

Add modal dialog support to a confirm form.

Parameters

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

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

Return value

array The webform with modal dialog support.

5 calls to WebformDialogFormTrait::buildDialogConfirmForm()
WebformConfigEntityDeleteFormBase::buildForm in src/Form/WebformConfigEntityDeleteFormBase.php
Form constructor.
WebformDeleteFormBase::buildForm in src/Form/WebformDeleteFormBase.php
Form constructor.
WebformDevelEntityFormApiTestForm::buildForm in modules/webform_devel/src/Form/WebformDevelEntityFormApiTestForm.php
Form constructor.
WebformSubmissionDeleteForm::buildForm in src/Form/WebformSubmissionDeleteForm.php
Form constructor.
WebformUiElementDeleteForm::buildForm in modules/webform_ui/src/Form/WebformUiElementDeleteForm.php
Form constructor.

File

src/Form/WebformDialogFormTrait.php, line 53

Class

WebformDialogFormTrait
Trait class for Webform Ajax dialog support.

Namespace

Drupal\webform\Form

Code

protected function buildDialogConfirmForm(array &$form, FormStateInterface $form_state) {
  if (!$this
    ->isDialog() || $this
    ->isOffCanvasDialog()) {
    return $form;
  }
  $this
    ->buildDialogForm($form, $form_state);

  // Replace 'Cancel' link button with a close dialog button.
  $form['actions']['cancel'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Cancel'),
    '#validate' => [
      '::noValidate',
    ],
    '#submit' => [
      '::noSubmit',
    ],
    '#weight' => 100,
    '#ajax' => [
      'callback' => '::cancelAjaxForm',
      'event' => 'click',
    ],
  ];
  return $form;
}