public function CourseEnrollmentSettingsForm::buildForm in Course 3.x
Same name and namespace in other branches
- 8.3 src/Form/CourseEnrollmentSettingsForm.php \Drupal\course\Form\CourseEnrollmentSettingsForm::buildForm()
- 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\FormCode
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);
}