You are here

protected function WebformImageSelectImagesForm::copyFormValuesToEntity in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_image_select/src/WebformImageSelectImagesForm.php \Drupal\webform_image_select\WebformImageSelectImagesForm::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 EntityForm::copyFormValuesToEntity

File

modules/webform_image_select/src/WebformImageSelectImagesForm.php, line 215

Class

WebformImageSelectImagesForm
Provides a form to set webform image select images.

Namespace

Drupal\webform_image_select

Code

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

  /** @var \Drupal\webform_image_select\WebformImageSelectImagesInterface $entity */
  $values = $form_state
    ->getValues();
  if (is_array($values['images'])) {
    $entity
      ->setImages($values['images']);
    unset($values['images']);
  }
  foreach ($values as $key => $value) {
    $entity
      ->set($key, $value);
  }
}