You are here

protected function SliderProForm::copyFormValuesToEntity in Slider Pro 8

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/Form/SliderProForm.php, line 501

Class

SliderProForm
Class SliderProForm @package Drupal\slider_pro\Form

Namespace

Drupal\slider_pro\Form

Code

protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
  $options = [];
  $values = $form_state
    ->getValues();
  foreach ($values as $key => $value) {
    if (in_array($key, [
      'id',
      'label',
    ])) {
      $entity
        ->set($key, $value);
    }
    else {
      $options[$key] = $value;
    }
  }
  $entity
    ->set('options', $options);
}