You are here

public function QuizFeedbackTypeForm::form in Quiz 6.x

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/Form/QuizFeedbackTypeForm.php, line 17

Class

QuizFeedbackTypeForm
Edit form for feedback types.

Namespace

Drupal\quiz\Form

Code

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