You are here

public function TestMailForm::buildForm in Sparkpost email 8

Same name and namespace in other branches
  1. 8.2 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 54

Class

TestMailForm
Class TestMailForm.

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: !link', [
      '!link' => Link::fromTextAndUrl($this
        ->t('link'), Url::fromUri('http://www.drupal.org/project/sparkpost'))
        ->toString(),
    ]),
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => t('Send'),
  ];
  return $form;
}