You are here

public function SubscriptionsBlockForm::form in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 src/Form/SubscriptionsBlockForm.php \Drupal\simplenews\Form\SubscriptionsBlockForm::form()
  2. 8 src/Form/SubscriptionsBlockForm.php \Drupal\simplenews\Form\SubscriptionsBlockForm::form()

Gets the actual form array to be built.

Overrides SubscriptionsFormBase::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

src/Form/SubscriptionsBlockForm.php, line 51

Class

SubscriptionsBlockForm
Add subscriptions for authenticated user or new subscriber.

Namespace

Drupal\simplenews\Form

Code

public function form(array $form, FormStateInterface $form_state) {

  // Hide subscription widget if only one newsletter available.
  if (count($this
    ->getNewsletters()) == 1) {
    $this
      ->getSubscriptionWidget($form_state)
      ->setHidden();
  }
  $form = parent::form($form, $form_state);
  $form['subscriptions']['widget']['#title'] = $this
    ->t('Manage your newsletter subscriptions');
  $form['subscriptions']['widget']['#description'] = $this
    ->t('Select the newsletter(s) to which you want to subscribe.');
  if ($this->message) {
    $form['message'] = [
      '#type' => 'item',
      '#markup' => $this->message,
    ];
  }
  return $form;
}