You are here

public function TestMailForm::buildForm in Sparkpost email 8.2

Same name and namespace in other branches
  1. 8 src/Form/TestMailForm.php \Drupal\sparkpost\Form\TestMailForm::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

src/Form/TestMailForm.php, line 64

Class

TestMailForm
The form for sending test mails from Sparkpost.

Namespace

Drupal\sparkpost\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['recipient'] = [
    '#type' => 'email',
    '#title' => $this
      ->t('Recipient'),
    '#required' => TRUE,
    '#default_value' => $this
      ->configFactory()
      ->get('system.site')
      ->get('mail'),
  ];
  $form['subject'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Subject'),
    '#maxlength' => 255,
    '#default_value' => $this
      ->t('Drupal Sparkpost test email'),
  ];
  $form['body'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Body'),
    '#default_value' => $this
      ->t('If you receive this message it means your site is capable of using Sparkpost to send email. This url is here to test click tracking: <a href=":link">link</a>', [
      ':link' => Url::fromUri('http://www.drupal.org/project/sparkpost')
        ->toString(),
    ]),
  ];
  $form['attachment'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Add attachment'),
    '#default_value' => TRUE,
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Send'),
  ];
  return $form;
}