You are here

public function ModuleConfigureForm::buildForm in Open Social 8.9

Same name and namespace in other branches
  1. 8.8 src/Installer/Form/ModuleConfigureForm.php \Drupal\social\Installer\Form\ModuleConfigureForm::buildForm()
  2. 10.3.x src/Installer/Form/ModuleConfigureForm.php \Drupal\social\Installer\Form\ModuleConfigureForm::buildForm()
  3. 10.0.x src/Installer/Form/ModuleConfigureForm.php \Drupal\social\Installer\Form\ModuleConfigureForm::buildForm()
  4. 10.1.x src/Installer/Form/ModuleConfigureForm.php \Drupal\social\Installer\Form\ModuleConfigureForm::buildForm()
  5. 10.2.x src/Installer/Form/ModuleConfigureForm.php \Drupal\social\Installer\Form\ModuleConfigureForm::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/Installer/Form/ModuleConfigureForm.php, line 65

Class

ModuleConfigureForm
Provides the site configuration form.

Namespace

Drupal\social\Installer\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['#title'] = $this
    ->t('Install optional modules');
  $form['description'] = [
    '#type' => 'item',
    '#markup' => $this
      ->t('All the required modules and configuration will be automatically installed and imported. You can optionally select additional features or generated demo content.'),
  ];
  $form['install_modules'] = [
    '#type' => 'container',
  ];

  // Allow automated installs to easily select all optional modules.
  $form['install_modules']['select_all'] = [
    '#type' => 'checkbox',
    '#label' => 'Install all features',
    '#attributes' => [
      'class' => [
        'visually-hidden',
      ],
    ],
  ];
  $optional_features = $this->optionalModuleManager
    ->getOptionalModules();
  $feature_options = array_map(static function ($info) {
    return $info['name'];
  }, $optional_features);
  $default_features = array_keys(array_filter($optional_features, static function ($info) {
    return $info['default'];
  }));

  // Checkboxes to enable Optional modules.
  $form['install_modules']['optional_modules'] = [
    '#type' => 'checkboxes',
    '#title' => t('Enable additional features'),
    '#options' => $feature_options,
    '#default_value' => $default_features,
  ];
  $form['install_demo'] = [
    '#type' => 'container',
  ];
  $form['install_demo']['demo_content'] = [
    '#type' => 'checkbox',
    '#title' => t('Generate demo content and users'),
    '#description' => t('Will generate files, users, groups, events, topics, comments and posts.'),
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['save'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save and continue'),
    '#button_type' => 'primary',
    '#submit' => [
      '::submitForm',
    ],
  ];
  return $form;
}