You are here

public function YamlFormEntityForm::buildForm in YAML Form 8

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/YamlFormEntityForm.php, line 92

Class

YamlFormEntityForm
Base for controller for form.

Namespace

Drupal\yamlform

Code

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

  /** @var \Drupal\yamlform\YamlFormInterface $yamlform */
  $yamlform = $this
    ->getEntity();

  // Customize title for duplicate form.
  if ($this->operation == 'duplicate') {

    // Display custom title.
    $form['#title'] = $this
      ->t("Duplicate '@label' form", [
      '@label' => $yamlform
        ->label(),
    ]);

    // If template, clear template's description and remove template flag.
    if ($yamlform
      ->isTemplate()) {
      $yamlform
        ->set('description', '');
      $yamlform
        ->set('template', FALSE);
    }
  }
  $form = parent::buildForm($form, $form_state);
  $form = $this
    ->buildDialog($form, $form_state);
  return $form;
}