You are here

public function SubscriptionsFormBase::form in Simplenews 8.2

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

Gets the actual form array to be built.

Overrides ContentEntityForm::form

See also

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

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

2 calls to SubscriptionsFormBase::form()
SubscriberForm::form in src/Form/SubscriberForm.php
Gets the actual form array to be built.
SubscriptionsBlockForm::form in src/Form/SubscriptionsBlockForm.php
Gets the actual form array to be built.
2 methods override SubscriptionsFormBase::form()
SubscriberForm::form in src/Form/SubscriberForm.php
Gets the actual form array to be built.
SubscriptionsBlockForm::form in src/Form/SubscriptionsBlockForm.php
Gets the actual form array to be built.

File

src/Form/SubscriptionsFormBase.php, line 135

Class

SubscriptionsFormBase
Entity form for Subscriber with common routines.

Namespace

Drupal\simplenews\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $this
    ->getSubscriptionWidget($form_state)
    ->setAvailableNewsletterIds(array_keys($this
    ->getNewsletters()));
  $form = parent::form($form, $form_state);

  // Modify UI texts.
  if ($mail = $this->entity
    ->getMail()) {
    $form['subscriptions']['widget']['#title'] = $this
      ->t('Subscriptions for %mail', [
      '%mail' => $mail,
    ]);
    $form['subscriptions']['widget']['#description'] = $this
      ->t('Check the newsletters you want to subscribe to. Uncheck the ones you want to unsubscribe from.');
  }
  else {
    $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 or unsubscribe.');
  }
  return $form;
}