You are here

public function SubscriberMassUnsubscribeForm::buildForm in Simplenews 8.2

Same name and namespace in other branches
  1. 8 src/Form/SubscriberMassUnsubscribeForm.php \Drupal\simplenews\Form\SubscriberMassUnsubscribeForm::buildForm()
  2. 3.x src/Form/SubscriberMassUnsubscribeForm.php \Drupal\simplenews\Form\SubscriberMassUnsubscribeForm::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/SubscriberMassUnsubscribeForm.php, line 64

Class

SubscriberMassUnsubscribeForm
Do a mass subscription for a list of email addresses.

Namespace

Drupal\simplenews\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['emails'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Email addresses'),
    '#cols' => 60,
    '#rows' => 5,
    '#description' => $this
      ->t('Email addresses must be separated by comma, space or newline.'),
  ];
  $form['newsletters'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Unsubscribe from'),
    '#options' => simplenews_newsletter_list(),
    '#required' => TRUE,
  ];
  foreach (simplenews_newsletter_get_all() as $id => $newsletter) {
    $form['newsletters'][$id]['#description'] = Html::escape($newsletter->description);
  }
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Unsubscribe'),
  ];
  return $form;
}