You are here

public function EventSettingsForm::buildForm in Open Social 10.2.x

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 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  3. 8.2 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  4. 8.3 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  5. 8.4 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  6. 8.5 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  7. 8.6 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  8. 8.7 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  9. 8.8 modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  10. 10.3.x modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  11. 10.0.x modules/social_features/social_event/src/Form/EventSettingsForm.php \Drupal\social_event\Form\EventSettingsForm::buildForm()
  12. 10.1.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 81

Class

EventSettingsForm
Class EventSettingsForm.

Namespace

Drupal\social_event\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Get the config.
  $social_event_config = $this->configFactory
    ->getEditable('social_event.settings');
  $form['event_display'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Event display settings'),
    '#open' => TRUE,
  ];
  $form['event_display']['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' => $social_event_config
      ->get('enroll') ?: [],
    '#states' => [
      'visible' => [
        ':input[name="enroll"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];

  /** @var \Drupal\group\Entity\GroupTypeInterface[] $group_types*/
  $group_types = $this->entityTypeManager
    ->getStorage('group_type')
    ->loadMultiple();
  foreach ($group_types as $group_type) {

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

      // Add to the option array.
      $form['event_display']['enroll']['#options'][$group_type
        ->id()] = $group_type
        ->label();
    }
  }
  $form['event_display']['address_visibility_settings'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Address visibility settings'),
    '#options' => [
      'street_code_private' => $this
        ->t('Only show street and postal code to event enrollees'),
    ],
    '#default_value' => $social_event_config
      ->get('address_visibility_settings') ?: [],
  ];
  $form['event_display']['show_user_timezone'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display user’s time zone in events'),
    '#description' => $this
      ->t('If enabled, user’s own time zone will be displayed after the event date and time.'),
    '#default_value' => $social_event_config
      ->get('show_user_timezone'),
  ];
  $form['event_enrolment'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Event enrollment settings'),
    '#open' => TRUE,
  ];
  $form['event_enrolment']['disable_event_enroll'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Disable all event enrollments on your community.'),
    '#description' => $this
      ->t('If disabled, event organizers can decide to disable or enable event enrollments when creating or editing an event.'),
    '#default_value' => $social_event_config
      ->get('disable_event_enroll'),
  ];
  return parent::buildForm($form, $form_state);
}