diff --git a/src/Form/AdmissionRequirementsForm.php b/src/Form/AdmissionRequirementsForm.php index 9802c7f0c4982837afee70dfeb570ea18382b322..46eea5d1fb1237adabbe2e704dec6c6c02c33f68 100644 --- a/src/Form/AdmissionRequirementsForm.php +++ b/src/Form/AdmissionRequirementsForm.php @@ -152,6 +152,7 @@ class AdmissionRequirementsForm extends FormBase { 'select[name="high_school"]' => ['!value' => 9998], ], ], + '#default_value' => $form_settings['advanced_study_default_value'], ]; // THe country system options. diff --git a/src/Form/AdmissionRequirementsFormSettings.php b/src/Form/AdmissionRequirementsFormSettings.php index a84a7b9205a0733781fa1e738b3b6447e9530e7f..9072e17e0e93333de9b3d1cacfa31a00afdfda8e 100644 --- a/src/Form/AdmissionRequirementsFormSettings.php +++ b/src/Form/AdmissionRequirementsFormSettings.php @@ -280,7 +280,7 @@ class AdmissionRequirementsFormSettings extends ConfigFormBase { // The advanced study options. foreach ($options as $index => $option) { - $form['typical_wrapper']['advanced_study_options'][$index] = [ + $form['typical_wrapper']['advanced_study_options']['options'][$index] = [ '#type' => 'textfield', '#title' => $this->t('@title label', ['@title' => $advanced_study_options_names[$index]]), '#default_value' => $option, @@ -290,6 +290,14 @@ class AdmissionRequirementsFormSettings extends ConfigFormBase { ]; } + // The advanced study default value. + $form['typical_wrapper']['advanced_study_options']['default_value'] = [ + '#type' => 'select', + '#title' => $this->t('Advanced study default value'), + '#options' => $options, + '#default_value' => $config->get('advanced_study_default_value') ?? $defaults['typical']['advanced_study_default_value'], + ]; + // Have at least empty options. $options = []; @@ -540,9 +548,9 @@ class AdmissionRequirementsFormSettings extends ConfigFormBase { // Step through each of the advanced study options, and if no // label is entered, set an error. foreach ($advanced_study_names as $index => $advanced_study_name) { - if (!$values['typical_wrapper']['advanced_study_options'][$index]) { + if (!$values['typical_wrapper']['advanced_study_options']['options'][$index]) { $form_state->setError( - $form['typical_wrapper']['advanced_study_options'][$index], + $form['typical_wrapper']['advanced_study_options']['options'][$index], $this->t( 'You must enter a label for the @label.', ['@label' => $advanced_study_name] @@ -788,7 +796,8 @@ class AdmissionRequirementsFormSettings extends ConfigFormBase { ->set('high_school_student_label', $values['typical_wrapper']['high_school_student_label']) ->set('high_school_student_default_value', $values['typical_wrapper']['high_school_student_default_value']) ->set('advanced_study_label', $values['typical_wrapper']['advanced_study_label']) - ->set('advanced_study_options', $values['typical_wrapper']['advanced_study_options']) + ->set('advanced_study_options', $values['typical_wrapper']['advanced_study_options']['options']) + ->set('advanced_study_default_value', $values['typical_wrapper']['advanced_study_options']['default_value']) ->set('country_system_study_label', $values['typical_wrapper']['country_system_study_label']) ->set('country_label', $values['typical_wrapper']['country_label']) ->set('program_label', $values['typical_wrapper']['program_label']) @@ -836,6 +845,7 @@ class AdmissionRequirementsFormSettings extends ConfigFormBase { 'ib' => 'International Baccalaureate (IB) courses or diploma', 'none' => 'None of the above', ]; + $defaults['typical']['advanced_study_default_value'] = 'none'; $defaults['typical']['country_system_study_label'] = 'Country/System of study'; $defaults['typical']['country_label'] = 'Country'; $defaults['typical']['program_label'] = "I'm interested in";