public function ProtectedPagesSendEmailForm::buildForm in Protected Pages 8
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
- src/
Form/ ProtectedPagesSendEmailForm.php, line 124
Class
- ProtectedPagesSendEmailForm
- Provides send protected pages details email form.
Namespace
Drupal\protected_pages\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) {
$config = $this->configFactory
->getEditable('protected_pages.settings');
$form['send_email_box'] = [
'#type' => 'details',
'#title' => $this
->t('Send email'),
'#description' => $this
->t('You send details of this protected page by email to multiple users. Please click <a href="@here">here</a> to configure email settings.', [
'@here' => Url::fromUri('internal:/admin/config/system/protected_pages/settings', [
'query' => $this
->getDestinationArray(),
])
->toString(),
]),
'#open' => TRUE,
];
$form_state
->set('pid', $pid);
$form['send_email_box']['recipents'] = [
'#type' => 'textarea',
'#title' => $this
->t('Recipents'),
'#rows' => 5,
'#description' => $this
->t('Enter comma separated list of recipients.'),
'#required' => TRUE,
];
$form['send_email_box']['subject'] = [
'#type' => 'textfield',
'#title' => $this
->t('Subject'),
'#default_value' => $config
->get('email.subject'),
'#description' => $this
->t('Enter email subject.'),
'#required' => TRUE,
];
$form['send_email_box']['body'] = [
'#type' => 'textarea',
'#title' => $this
->t('Email body'),
'#rows' => 15,
'#default_value' => $config
->get('email.body'),
'#description' => $this
->t('Enter the body of the email. Only [protected-page-url] and [site-name] tokens are available.
Since password is encrypted, therefore we can not provide it by token.'),
'#required' => TRUE,
];
$form['send_email_box']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Send email'),
];
return $form;
}