You are here

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

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

File

modules/social_features/social_event/src/Form/EnrollRequestModalForm.php, line 28

Class

EnrollRequestModalForm
SendToDestinationsForm class.

Namespace

Drupal\social_event\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $options = NULL) {
  $node = \Drupal::routeMatch()
    ->getParameter('node');
  $nid = $node
    ->id();
  $form['#prefix'] = '<div id="request_enrollment">';
  $form['#suffix'] = '</div>';

  // The status messages that will contain any form errors.
  $form['status_messages'] = [
    '#type' => 'status_messages',
    '#weight' => -10,
  ];
  $form['event'] = [
    '#type' => 'hidden',
    '#value' => $nid,
  ];
  $form['description'] = [
    '#type' => 'html_tag',
    '#tag' => 'p',
    '#value' => $this
      ->t('You can leave a message in your request. Only when your request is approved, you will receive a notification via email and notification center.'),
  ];
  $form['message'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Message'),
    '#maxlength' => 250,
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Send request'),
    '#button_type' => 'primary',
    '#ajax' => [
      'callback' => [
        $this,
        'submitModalFormAjax',
      ],
      'event' => 'click',
    ],
  ];
  $form['#attached']['library'] = [
    'core/drupal.dialog.ajax',
    'social_event/modal',
  ];
  $form['#attached']['drupalSettings']['eventEnrollmentRequest'] = [
    'closeDialog' => TRUE,
  ];
  return $form;
}