You are here

protected function WebformOptionsCustomForm::copyFormValuesToEntity in Webform 8.5

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

1 call to WebformOptionsCustomForm::copyFormValuesToEntity()
WebformOptionsCustomForm::validateForm in modules/webform_options_custom/src/WebformOptionsCustomForm.php
Form validation handler.

File

modules/webform_options_custom/src/WebformOptionsCustomForm.php, line 474

Class

WebformOptionsCustomForm
Provides a form to set webform options custom.

Namespace

Drupal\webform_options_custom

Code

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

  /** @var \Drupal\webform_options_custom\WebformOptionsCustomInterface $entity */
  $values = $form_state
    ->getValues();
  if (is_array($values['options'])) {
    $entity
      ->setOptions($values['options']);
    unset($values['options']);
  }
  foreach ($values as $key => $value) {
    $entity
      ->set($key, $value);
  }
}