You are here

public function WebformVariantEditForm::buildForm in Webform 6.x

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

Form constructor.

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\webform\WebformInterface $webform: The webform.

string $webform_variant: The webform variant ID.

Return value

array The form structure.

Throws

\Symfony\Component\HttpKernel\Exception\NotFoundHttpException Throws not found exception if the number of variant instances for this webform exceeds the variant's cardinality.

Overrides WebformVariantFormBase::buildForm

File

src/Form/WebformVariantEditForm.php, line 17

Class

WebformVariantEditForm
Provides an edit form for webform variants.

Namespace

Drupal\webform\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, WebformInterface $webform = NULL, $webform_variant = NULL) {
  $form = parent::buildForm($form, $form_state, $webform, $webform_variant);
  $form['#title'] = $this
    ->t('Edit @label variant', [
    '@label' => $this->webformVariant
      ->label(),
  ]);

  // Delete action.
  $url = new Url('entity.webform.variant.delete_form', [
    'webform' => $webform
      ->id(),
    'webform_variant' => $this->webformVariant
      ->getVariantId(),
  ]);
  $this
    ->buildDialogDeleteAction($form, $form_state, $url);
  return $form;
}