You are here

public function WebformVariantApplyForm::getWarning in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Form/WebformVariantApplyForm.php \Drupal\webform\Form\WebformVariantApplyForm::getWarning()

Returns warning message to display.

Return value

array A renderable array containing a warning message.

Overrides WebformDeleteFormBase::getWarning

File

src/Form/WebformVariantApplyForm.php, line 56

Class

WebformVariantApplyForm
Form for apply a webform variant.

Namespace

Drupal\webform\Form

Code

public function getWarning() {
  if (!$this->hasMultipleVariants && $this->webformVariant) {
    $t_args = [
      '%title' => $this->webformVariant
        ->label(),
    ];
    return [
      '#type' => 'webform_message',
      '#message_type' => 'warning',
      '#message_message' => $this
        ->t('Are you sure you want to apply the %title variant?', $t_args) . '<br/>' . '<strong>' . $this
        ->t('This action cannot be undone.') . '</strong>',
    ];
  }
  else {
    return [
      '#type' => 'webform_message',
      '#message_type' => 'warning',
      '#message_message' => $this
        ->t('Are you sure you want to apply the selected variants?') . '<br/>' . '<strong>' . $this
        ->t('This action cannot be undone.') . '</strong>',
    ];
  }
}