You are here

public function WebformOptionsCustomForm::buildForm in Webform 8.5

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

modules/webform_options_custom/src/WebformOptionsCustomForm.php, line 59

Class

WebformOptionsCustomForm
Provides a form to set webform options custom.

Namespace

Drupal\webform_options_custom

Code

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

  /** @var \Drupal\webform_options_custom\WebformOptionsCustomInterface $webform_options_custom */
  $webform_options_custom = $this
    ->getEntity();

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