You are here

public function ModuleH5PAdminSettingsForm::buildForm in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/Form/ModuleH5PAdminSettingsForm.php \Drupal\opigno_module\Form\ModuleH5PAdminSettingsForm::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/ModuleH5PAdminSettingsForm.php, line 54

Class

ModuleH5PAdminSettingsForm
Class LearningPathAdminSettingsForm.

Namespace

Drupal\opigno_module\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $editor = H5PEditorUtilities::getInstance();
  $list = $editor
    ->getLatestGlobalLibrariesData();
  $options = [];
  foreach ($list as $item) {
    $options[$item['machineName']] = $item['title'] . ' (' . $item['machineName'] . ')';
  }
  $form['h5p_disabled'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Disabled H5P types'),
    '#options' => $options,
  );
  $not_recommended = $this
    ->disabledByDefault();
  foreach ($not_recommended as $item) {
    $form['h5p_disabled'][$item] = [
      '#disabled' => TRUE,
    ];
  }
  $config = $this
    ->config('opigno_module.settings');
  $disabled = $config
    ->get('disabled_h5p');
  $form['h5p_disabled']['#default_value'] = array_merge($not_recommended, $disabled);
  return parent::buildForm($form, $form_state);
}