You are here

public function SubscriptionsFormBase::form in Simplenews 8

Same name and namespace in other branches
  1. 8.2 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 134

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'] = t('Subscriptions for %mail', array(
      '%mail' => $mail,
    ));
    $form['subscriptions']['widget']['#description'] = t('Check the newsletters you want to subscribe to. Uncheck the ones you want to unsubscribe from.');
  }
  else {
    $form['subscriptions']['widget']['#title'] = t('Manage your newsletter subscriptions');
    $form['subscriptions']['widget']['#description'] = t('Select the newsletter(s) to which you want to subscribe or unsubscribe.');
  }
  return $form;
}