You are here

public function EventInviteSettingsForm::buildForm in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/modules/social_event_invite/src/Form/EventInviteSettingsForm.php \Drupal\social_event_invite\Form\EventInviteSettingsForm::buildForm()
  2. 10.3.x modules/social_features/social_event/modules/social_event_invite/src/Form/EventInviteSettingsForm.php \Drupal\social_event_invite\Form\EventInviteSettingsForm::buildForm()
  3. 10.0.x modules/social_features/social_event/modules/social_event_invite/src/Form/EventInviteSettingsForm.php \Drupal\social_event_invite\Form\EventInviteSettingsForm::buildForm()
  4. 10.2.x modules/social_features/social_event/modules/social_event_invite/src/Form/EventInviteSettingsForm.php \Drupal\social_event_invite\Form\EventInviteSettingsForm::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/modules/social_event_invite/src/Form/EventInviteSettingsForm.php, line 24

Class

EventInviteSettingsForm
Class EnrollInviteForm.

Namespace

Drupal\social_event_invite\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $social_event_config = $this->configFactory
    ->getEditable('social_event_invite.settings');

  // Add an introduction text to explain what can be done here.
  $form['introduction']['warning'] = [
    '#type' => 'html_tag',
    '#tag' => 'p',
    '#value' => $this
      ->t('Be aware that when disabling invites altogether or for a specific group type, the outstanding invites in question <em>are cancelled</em>. Invitees will no longer be able to use their invite link.'),
  ];
  $form['invite_enroll'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable invite enrollment to events'),
    '#description' => $this
      ->t('Enabling this feature provides the possibility to let event managers to invite people to their events.'),
    '#default_value' => $social_event_config
      ->get('invite_enroll'),
  ];
  $group_types = [];

  /** @var \Drupal\group\Entity\GroupType $group_type */
  foreach (GroupType::loadMultiple() as $group_type) {
    $group_types[$group_type
      ->id()] = $group_type
      ->label();
  }
  $form['invite_group_types'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Enable event invite per group type'),
    '#description' => $this
      ->t('Select the group types for which you want to enable the event invite feature.'),
    '#options' => $group_types,
    '#default_value' => $social_event_config
      ->get('invite_group_types'),
  ];
  $form['invite_subject'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Subject'),
    '#default_value' => $social_event_config
      ->get('invite_subject'),
    '#required' => TRUE,
  ];
  $form['invite_message'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message'),
    '#default_value' => $social_event_config
      ->get('invite_message'),
    '#required' => TRUE,
  ];
  $form['invite_helper'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Helper'),
    '#default_value' => $social_event_config
      ->get('invite_helper'),
    '#required' => TRUE,
    '#rows' => '2',
  ];
  $form['email_verification'] = [
    '#type' => 'checkbox',
    '#title' => t('Allow invited user to skip email verification'),
    '#default_value' => $social_event_config
      ->get('email_verification'),
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#button_type' => 'primary',
    '#button_level' => 'raised',
    '#value' => $this
      ->t('Save configuration'),
  ];
  return $form;
}