You are here

public function CourseEnrollmentTypeForm::form in Course 3.x

Same name and namespace in other branches
  1. 8.3 src/Form/CourseEnrollmentTypeForm.php \Drupal\course\Form\CourseEnrollmentTypeForm::form()
  2. 8.2 src/Form/CourseEnrollmentTypeForm.php \Drupal\course\Form\CourseEnrollmentTypeForm::form()

inheritdoc}

Overrides EntityForm::form

File

src/Form/CourseEnrollmentTypeForm.php, line 14

Class

CourseEnrollmentTypeForm

Namespace

Drupal\course\Form

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\\course\\Entity\\CourseEnrollmentType::load',
      'source' => [
        'label',
      ],
    ],
  ];
  return $form;
}