You are here

public function EventSettingsForm::buildForm in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  2. 8.2 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  3. 8.3 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  4. 8.4 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  5. 8.5 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  6. 8.6 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  7. 8.7 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  8. 8.8 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  9. 10.3.x modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  10. 10.0.x modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  11. 10.1.x modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  12. 10.2.x modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::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

modules/social_features/social_event/src/Form/EventSettingsForm.php, line 35

Class

EventSettingsForm
Class EventSettingsForm.

Namespace

Drupal\social_event\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $group_type_ids = $this->configFactory
    ->getEditable('social_event.settings')
    ->get('enroll');
  $form['enroll'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Enroll user which is not group member'),
    '#description' => $this
      ->t('Enroll button should be visible for users that are not in the group and automatic enroll people to groups when they enroll to events that are part of the group.'),
    '#default_value' => $group_type_ids,
    '#states' => [
      'visible' => [
        ':input[name="enroll"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];

  /** @var \Drupal\group\Entity\GroupTypeInterface $group_type */
  foreach (GroupType::loadMultiple() as $group_type) {

    // Check if this group type uses events.
    if ($group_type
      ->hasContentPlugin('group_node:event')) {

      // Add to the option array.
      $form['enroll']['#options'][$group_type
        ->id()] = $group_type
        ->label();
    }
  }
  return parent::buildForm($form, $form_state);
}