protected function CorrespondingReferenceForm::copyFormValuesToEntity in Corresponding Entity References 8.4
Copies form values into the config entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The config entity.
array $form: The form.
\Drupal\Core\Form\FormStateInterface $form_state: The form state object.
Overrides EntityForm::copyFormValuesToEntity
File
- src/
Form/ CorrespondingReferenceForm.php, line 284
Class
- CorrespondingReferenceForm
- Form handler for corresponding reference add and edit forms.
Namespace
Drupal\cer\FormCode
protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
if ($this->entity instanceof EntityWithPluginCollectionInterface) {
// Do not manually update values represented by plugin collections.
$values = array_diff_key($values, $this->entity
->getPluginCollections());
}
/** @var CorrespondingReferenceInterface $entity */
$entity
->set('id', $values['id']);
$entity
->set('label', $values['label']);
$entity
->set('first_field', $values['first_field']);
$entity
->set('second_field', $values['second_field']);
$entity
->set('bundles', $this
->getBundleValuesForEntity($values['bundles']));
$entity
->set('enabled', $values['enabled']);
}