You are here

public function WebformOptionsForm::buildForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformOptionsForm.php \Drupal\webform\WebformOptionsForm::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.

Return value

array The form structure.

Overrides EntityForm::buildForm

File

src/WebformOptionsForm.php, line 50

Class

WebformOptionsForm
Provides a form to set options.

Namespace

Drupal\webform

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  /** @var \Drupal\webform\WebformOptionsInterface $webform_options */
  $webform_options = $this
    ->getEntity();

  // Customize title for duplicate and edit operation.
  switch ($this->operation) {
    case 'duplicate':
      $form['#title'] = $this
        ->t("Duplicate '@label' options", [
        '@label' => $webform_options
          ->label(),
      ]);
      break;
    case 'edit':
    case 'source':
      $form['#title'] = $webform_options
        ->label();
      break;
  }
  return parent::buildForm($form, $form_state);
}