You are here

protected function SubscriptionsFormBase::copyFormValuesToEntity in Simplenews 8

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

Copies top-level form values to entity properties

This should not change existing entity properties that are not being edited by this form.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the current form should operate upon.

array $form: A nested array of form elements comprising the form.

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

Overrides ContentEntityForm::copyFormValuesToEntity

File

src/Form/SubscriptionsFormBase.php, line 247

Class

SubscriptionsFormBase
Entity form for Subscriber with common routines.

Namespace

Drupal\simplenews\Form

Code

protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {

  // Subscriptions are handled later, in the submit callbacks through
  // ::getSelectedNewsletters(). Letting them be copied here would break
  // subscription management.
  $subsciptions_value = $form_state
    ->getValue('subscriptions');
  $form_state
    ->unsetValue('subscriptions');
  parent::copyFormValuesToEntity($entity, $form, $form_state);
  $form_state
    ->setValue('subscriptions', $subsciptions_value);
}