You are here

public function CourseEnrollmentSettingsForm::buildForm in Course 3.x

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

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/CourseEnrollmentSettingsForm.php, line 24

Class

CourseEnrollmentSettingsForm
Course enrollment settings form.

Namespace

Drupal\course\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('course.settings.enrollment');
  $types = CourseEnrollmentType::loadMultiple();
  $options = array_column($types, 'label', 'id');
  $form['default_enrollment_type'] = [
    '#title' => t('Default course enrollment type'),
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => $config
      ->get('default_enrollment_type'),
  ];
  return parent::buildForm($form, $form_state);
}