3 namespace Drupal\Core\Installer\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Provides the profile selection form.
11 class SelectProfileForm extends FormBase {
16 public function getFormId() {
17 return 'install_select_profile_form';
23 public function buildForm(array $form, FormStateInterface $form_state, $install_state = NULL) {
24 $form['#title'] = $this->t('Select an installation profile');
28 foreach ($install_state['profiles'] as $profile) {
29 /** @var $profile \Drupal\Core\Extension\Extension */
30 $details = install_profile_info($profile->getName());
31 // Don't show hidden profiles. This is used by to hide the testing profile,
32 // which only exists to speed up test runs.
33 if ($details['hidden'] === TRUE && !drupal_valid_test_ua()) {
36 $profiles[$profile->getName()] = $details;
38 // Determine the name of the profile; default to file name if defined name
40 $name = isset($details['name']) ? $details['name'] : $profile->getName();
41 $names[$profile->getName()] = $name;
44 // Display radio buttons alphabetically by human-readable name, but always
45 // put the core profiles first (if they are present in the filesystem).
47 if (isset($names['minimal'])) {
48 // If the expert ("Minimal") core profile is present, put it in front of
49 // any non-core profiles rather than including it with them alphabetically,
50 // since the other profiles might be intended to group together in a
52 $names = ['minimal' => $names['minimal']] + $names;
54 if (isset($names['standard'])) {
55 // If the default ("Standard") core profile is present, put it at the very
56 // top of the list. This profile will have its radio button pre-selected,
57 // so we want it to always appear at the top.
58 $names = ['standard' => $names['standard']] + $names;
61 // The profile name and description are extracted for translation from the
62 // .info file, so we can use $this->t() on them even though they are dynamic
63 // data at this point.
66 '#title' => $this->t('Select an installation profile'),
67 '#title_display' => 'invisible',
68 '#options' => array_map([$this, 't'], $names),
69 '#default_value' => 'standard',
71 foreach (array_keys($names) as $profile_name) {
72 $form['profile'][$profile_name]['#description'] = isset($profiles[$profile_name]['description']) ? $this->t($profiles[$profile_name]['description']) : '';
74 $form['actions'] = ['#type' => 'actions'];
75 $form['actions']['submit'] = [
77 '#value' => $this->t('Save and continue'),
78 '#button_type' => 'primary',
86 public function submitForm(array &$form, FormStateInterface $form_state) {
87 global $install_state;
88 $install_state['parameters']['profile'] = $form_state->getValue('profile');