You are here

protected function PaymentStatusForm::copyFormValuesToEntity in Payment 8.2

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 EntityForm::copyFormValuesToEntity

File

src/Entity/PaymentStatus/PaymentStatusForm.php, line 125

Class

PaymentStatusForm
Provides the payment status add/edit form.

Namespace

Drupal\payment\Entity\PaymentStatus

Code

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

  /** @var \Drupal\payment\Entity\PaymentStatusInterface $payment_status */
  parent::copyFormValuesToEntity($payment_status, $form, $form_state);
  $values = $form_state
    ->getValues();
  $payment_status
    ->setId($values['id']);
  $payment_status
    ->setLabel($values['label']);
  $selected_parent = $this
    ->getParentPaymentStatusSelector($form_state)
    ->getSelectedPlugin();
  $payment_status
    ->setParentId($selected_parent ? $selected_parent
    ->getPluginId() : NULL);
  $payment_status
    ->setDescription($values['description']);
}