public function EnrollRequestAnonymousForm::buildForm in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/src/Form/EnrollRequestAnonymousForm.php \Drupal\social_event\Form\EnrollRequestAnonymousForm::buildForm()
- 10.3.x modules/social_features/social_event/src/Form/EnrollRequestAnonymousForm.php \Drupal\social_event\Form\EnrollRequestAnonymousForm::buildForm()
- 10.0.x modules/social_features/social_event/src/Form/EnrollRequestAnonymousForm.php \Drupal\social_event\Form\EnrollRequestAnonymousForm::buildForm()
- 10.1.x modules/social_features/social_event/src/Form/EnrollRequestAnonymousForm.php \Drupal\social_event\Form\EnrollRequestAnonymousForm::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/ EnrollRequestAnonymousForm.php, line 24
Class
- EnrollRequestAnonymousForm
- Provides a form to request event enrollment for anonymous.
Namespace
Drupal\social_event\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $options = NULL) {
$node = \Drupal::routeMatch()
->getParameter('node');
$nid = $node
->id();
$node_url = Url::fromRoute('entity.node.canonical', [
'node' => $nid,
])
->toString();
$form['description'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $this
->t('In order to send your request, please first sign up or log in.'),
];
$form['actions']['#type'] = 'actions';
$form['actions']['sign_up'] = [
'#type' => 'link',
'#title' => $this
->t('Sign up'),
'#attributes' => [
'class' => [
'btn',
'btn-primary',
'waves-effect',
'waves-btn',
],
],
'#url' => Url::fromRoute('user.register'),
];
$form['actions']['log_in'] = [
'#type' => 'link',
'#title' => $this
->t('Log in'),
'#attributes' => [
'class' => [
'btn',
'btn-default',
'waves-effect',
'waves-btn',
],
],
'#url' => Url::fromRoute('user.login', [
'destination' => $node_url . '?requested-enrollment=TRUE',
]),
];
$form['#attached']['library'] = [
'social_event/modal',
];
return $form;
}