protected function WishlistItemDetailsForm::copyFormValuesToEntity in Commerce Wishlist 8.3
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/ WishlistItemDetailsForm.php, line 105
Class
- WishlistItemDetailsForm
- Provides the wishlist details form.
Namespace
Drupal\commerce_wishlist\FormCode
protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
assert($entity instanceof WishlistItemInterface);
$values = $form_state
->getValues();
unset($values['action']);
foreach ($values as $key => $value) {
if ($entity
->hasField($key)) {
$entity
->set($key, $value);
}
}
}