You are here

public function EntityTestForm::form in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/entity_test/src/EntityTestForm.php \Drupal\entity_test\EntityTestForm::form()

Gets the actual form array to be built.

Overrides ContentEntityForm::form

See also

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

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

File

core/modules/system/tests/modules/entity_test/src/EntityTestForm.php, line 33
Contains \Drupal\entity_test\EntityTestForm.

Class

EntityTestForm
Form controller for the test entity edit forms.

Namespace

Drupal\entity_test

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $entity = $this->entity;

  // @todo: Is there a better way to check if an entity type is revisionable?
  if ($entity
    ->getEntityType()
    ->hasKey('revision') && !$entity
    ->isNew()) {
    $form['revision'] = array(
      '#type' => 'checkbox',
      '#title' => t('Create new revision'),
      '#default_value' => $entity
        ->isNewRevision(),
    );
  }
  return $form;
}