You are here

public function SendGridTestForm::buildForm in SendGrid Integration 8

Same name and namespace in other branches
  1. 8.2 src/Form/SendGridTestForm.php \Drupal\sendgrid_integration\Form\SendGridTestForm::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/SendGridTestForm.php, line 77

Class

SendGridTestForm
Class SendGridSettingsForm.

Namespace

Drupal\sendgrid_integration\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('sendgrid_integration.settings');
  $form['from_name'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('From name'),
    '#default_value' => $config
      ->get('test_defaults.from_name'),
    '#maxlength' => 128,
  ];
  $form['to'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('To'),
    '#default_value' => $config
      ->get('test_defaults.to'),
    '#maxlength' => 128,
    '#required' => TRUE,
  ];
  $form['to_name'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('To Name'),
    '#default_value' => $config
      ->get('test_defaults.to_name'),
    '#maxlength' => 128,
  ];
  $form['reply_to'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Reply-To'),
    '#maxlength' => 128,
    '#default_value' => $config
      ->get('test_defaults.reply_to'),
  ];
  $form['subject'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Subject'),
    '#default_value' => $config
      ->get('test_defaults.subject'),
    '#maxlength' => 128,
    '#required' => TRUE,
  ];
  $form['include_attachment'] = [
    '#title' => $this
      ->t('Include attachment'),
    '#type' => 'checkbox',
    '#description' => t('If checked, the Drupal icon will be included as an attachment with the test email.'),
    '#default_value' => TRUE,
  ];
  $form['body'] = [
    '#type' => 'text_format',
    '#title' => $this
      ->t('Body'),
    '#rows' => 20,
    '#default_value' => $config
      ->get('test_defaults.body.value'),
    '#format' => $config
      ->get('test_defaults.body.format'),
    '#required' => TRUE,
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Send test message'),
  ];
  return $form;
}