You are here

public function SubscriptionsBlockForm::form in Simplenews 8.2

Same name and namespace in other branches
  1. 8 src/Form/SubscriptionsBlockForm.php \Drupal\simplenews\Form\SubscriptionsBlockForm::form()
  2. 3.x 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 49

Class

SubscriptionsBlockForm
Configure simplenews subscriptions of the logged user.

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);
  if ($this->message) {
    $form['message'] = [
      '#type' => 'item',
      '#markup' => $this->message,
    ];
  }
  return $form;
}