You are here

public function KeyEditForm::form in Key 8

Gets the actual form array to be built.

Overrides KeyFormBase::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

src/Form/KeyEditForm.php, line 74

Class

KeyEditForm
Class KeyEditForm.

Namespace

Drupal\key\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form['#title'] = $this
    ->t('Edit key %label', [
    '%label' => $this->entity
      ->label(),
  ]);

  // If editing has not been confirmed yet, display a warning and require
  // confirmation.
  if (!$this->editConfirmed) {
    $form['confirm_edit'] = [
      '#type' => 'markup',
      '#markup' => $this
        ->t('Be extremely careful when editing a key! It may result in broken site functionality. Are you sure you want to edit this key?'),
      '#prefix' => '<p>',
      '#suffix' => '</p>',
    ];
    return EntityForm::form($form, $form_state);
  }
  return parent::form($form, $form_state);
}