You are here

public function QuizTypeEntityForm::form in Quiz 8.6

Same name and namespace in other branches
  1. 8.5 src/Entity/QuizTypeEntityForm.php \Drupal\quiz\Entity\QuizTypeEntityForm::form()

Gets the actual form array to be built.

Overrides EntityForm::form

See also

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

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

File

src/Entity/QuizTypeEntityForm.php, line 14

Class

QuizTypeEntityForm

Namespace

Drupal\quiz\Entity

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $enrollment_type = $this->entity;
  $form['label'] = [
    '#title' => t('Label'),
    '#type' => 'textfield',
    '#default_value' => $enrollment_type
      ->label(),
    '#description' => t('The admin-facing name.'),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $enrollment_type
      ->id(),
    '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
    '#machine_name' => [
      'exists' => '\\Drupal\\quiz\\Entity\\QuizType::load',
      'source' => [
        'label',
      ],
    ],
  ];
  return $form;
}