public function EnrollInviteEmailForm::buildForm in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteEmailForm.php \Drupal\social_event_invite\Form\EnrollInviteEmailForm::buildForm()
- 10.3.x modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteEmailForm.php \Drupal\social_event_invite\Form\EnrollInviteEmailForm::buildForm()
- 10.1.x modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteEmailForm.php \Drupal\social_event_invite\Form\EnrollInviteEmailForm::buildForm()
- 10.2.x modules/social_features/social_event/modules/social_event_invite/src/Form/EnrollInviteEmailForm.php \Drupal\social_event_invite\Form\EnrollInviteEmailForm::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 InviteEmailBaseForm::buildForm
File
- modules/
social_features/ social_event/ modules/ social_event_invite/ src/ Form/ EnrollInviteEmailForm.php, line 95
Class
- EnrollInviteEmailForm
- Class EnrollInviteForm.
Namespace
Drupal\social_event_invite\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$form['#attributes']['class'][] = 'form--default';
$params = [
'user' => $this
->currentUser(),
'node' => $this->routeMatch
->getParameter('node'),
];
// Load event invite configuration.
$invite_config = $this->configFactory
->get('social_event_invite.settings');
// Cleanup message body and replace any links on invite preview page.
$body = $this->token
->replace($invite_config
->get('invite_message'), $params);
$body = preg_replace('/href="([^"]*)"/', 'href="#"', $body);
// Get default logo image and replace if it overridden with email settings.
$theme_id = $this->configFactory
->get('system.theme')
->get('default');
$logo = $this
->getRequest()
->getBaseUrl() . theme_get_setting('logo.url', $theme_id);
$email_logo = theme_get_setting('email_logo', $theme_id);
if (is_array($email_logo) && !empty($email_logo)) {
$file = File::load(reset($email_logo));
if ($file instanceof File) {
$logo = file_create_url($file
->getFileUri());
}
}
$form['email_preview'] = [
'#type' => 'fieldset',
'#title' => [
'text' => [
'#markup' => t('Preview your email invite'),
],
'icon' => [
'#markup' => '<svg class="icon icon-expand_more"><use xlink:href="#icon-expand_more" /></svg>',
'#allowed_tags' => [
'svg',
'use',
],
],
],
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attributes' => [
'class' => [
'form-horizontal',
'form-preview-email',
],
],
];
$form['email_preview']['preview'] = [
'#theme' => 'invite_email_preview',
'#logo' => $logo,
'#subject' => $this->token
->replace($invite_config
->get('invite_subject'), $params),
'#body' => $body,
'#helper' => $this->token
->replace($invite_config
->get('invite_helper'), $params),
];
$form['event'] = [
'#type' => 'hidden',
'#value' => $this->routeMatch
->getRawParameter('node'),
];
$form['actions']['submit_cancel'] = [
'#type' => 'submit',
'#weight' => 999,
'#value' => $this
->t('Back to event'),
'#submit' => [
[
$this,
'cancelForm',
],
],
'#limit_validation_errors' => [],
];
return $form;
}