You are here

public function SocialSettingsForm::buildForm in Opigno class 3.x

Same name and namespace in other branches
  1. 8 src/Form/SocialSettingsForm.php \Drupal\opigno_class\Form\SocialSettingsForm::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/SocialSettingsForm.php, line 41

Class

SocialSettingsForm
Class Social settings.

Namespace

Drupal\opigno_class\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('opigno_class.socialsettings');
  $form['social'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Social sharing'),
    '#options' => [
      self::NONE_USERS => 'no other student (only global managers. Drupal roles: user manager or content manager or administrator)',
      self::SAME_CLASS => 'the students sharing the same class(es)',
      self::SAME_TRAINING => 'the students sharing the same training(s)',
      self::SAME_USERS => 'the students sharing the class(es) + the training(s)',
      self::ALL_USERS => 'all the students',
    ],
    '#default_value' => $form_state
      ->hasValue('social') ? $form_state
      ->getValue('social') : $config
      ->get('social'),
    '#description' => $this
      ->t("Setting to define which users students can connect with."),
  ];
  return parent::buildForm($form, $form_state);
}