You are here

public function SubscriptionsFormBase::submitForm in Simplenews 8

Same name and namespace in other branches
  1. 8.2 src/Form/SubscriptionsFormBase.php \Drupal\simplenews\Form\SubscriptionsFormBase::submitForm()

This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state can be updated, this way the subsequently invoked handlers can retrieve a regular entity object to act on. Generally this method should not be overridden unless the entity requires the same preparation for two actions, see \Drupal\comment\CommentForm for an example with the save and preview actions.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ContentEntityForm::submitForm

2 calls to SubscriptionsFormBase::submitForm()
SubscriberForm::submitForm in src/Form/SubscriberForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
SubscriptionsAccountForm::submitForm in src/Form/SubscriptionsAccountForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
2 methods override SubscriptionsFormBase::submitForm()
SubscriberForm::submitForm in src/Form/SubscriberForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
SubscriptionsAccountForm::submitForm in src/Form/SubscriptionsAccountForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…

File

src/Form/SubscriptionsFormBase.php, line 232

Class

SubscriptionsFormBase
Entity form for Subscriber with common routines.

Namespace

Drupal\simplenews\Form

Code

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

  // Subclasses try to load an existing subscriber in different ways in
  // buildForm. For anonymous user the email is unknown in buildForm, but here
  // we can try again to load an existing subscriber.
  $mail = $form_state
    ->getValue(array(
    'mail',
    0,
    'value',
  ));
  if ($this->entity
    ->isNew() && isset($mail) && ($subscriber = simplenews_subscriber_load_by_mail($mail))) {
    $this
      ->setEntity($subscriber);
  }
  parent::submitForm($form, $form_state);
}