You are here

protected function WebformVariantDuplicateForm::prepareWebformVariant in Webform 6.x

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

Overrides WebformVariantAddForm::prepareWebformVariant

File

src/Form/WebformVariantDuplicateForm.php, line 25

Class

WebformVariantDuplicateForm
Provides a duplicate form for webform variant.

Namespace

Drupal\webform\Form

Code

protected function prepareWebformVariant($webform_variant) {
  $webform_variant = clone $this->webform
    ->getVariant($webform_variant);
  $webform_variant
    ->setVariantId(NULL);

  // Initialize the variant an pass in the webform.
  $webform_variant
    ->setWebform($this->webform);

  // Set the initial weight so this variant comes last.
  $webform_variant
    ->setWeight(count($this->webform
    ->getVariants()));
  return $webform_variant;
}