public function GroupRequestMembershipRequestAnonymousForm::buildForm in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRequestAnonymousForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRequestAnonymousForm::buildForm()
- 10.3.x modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRequestAnonymousForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRequestAnonymousForm::buildForm()
- 10.0.x modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRequestAnonymousForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRequestAnonymousForm::buildForm()
- 10.1.x modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRequestAnonymousForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRequestAnonymousForm::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_group/ modules/ social_group_request/ src/ Form/ GroupRequestMembershipRequestAnonymousForm.php, line 66
Class
- GroupRequestMembershipRequestAnonymousForm
- Provides a form to request group membership for anonymous.
Namespace
Drupal\social_group_request\FormCode
public function buildForm(array $form, FormStateInterface $form_state, GroupInterface $group = NULL) {
$this->group = $group;
$form['description'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $this
->t('In order to send your request, please first sign up or log in.'),
];
$previous_url = $this->requestStack
->getCurrentRequest()->headers
->get('referer');
$request = Request::create($previous_url);
$referer_path = $request
->getRequestUri();
$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', [
'destination' => $referer_path . '?requested-membership=' . $this->group
->id(),
]),
];
$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' => $referer_path . '?requested-membership=' . $this->group
->id(),
]),
];
return $form;
}