QuizFeedbackTypeForm.php in Quiz 6.x
File
src/Form/QuizFeedbackTypeForm.php
View source
<?php
namespace Drupal\quiz\Form;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
class QuizFeedbackTypeForm extends EntityForm {
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;
}
public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state);
$form_state
->setRedirect('entity.quiz_feedback_type.collection');
}
}