You are here

QuizTypeEntityForm.php in Quiz 8.6

Same filename and directory in other branches
  1. 8.5 src/Entity/QuizTypeEntityForm.php

Namespace

Drupal\quiz\Entity

File

src/Entity/QuizTypeEntityForm.php
View source
<?php

namespace Drupal\quiz\Entity;

use Drupal\Core\Entity\BundleEntityFormBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
class QuizTypeEntityForm extends BundleEntityFormBase {

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Classes

Namesort descending Description
QuizTypeEntityForm