public function EditQuantity::viewsFormSubmit in Commerce Wishlist 8.3
Submit handler for the views form.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
File
- src/
Plugin/ views/ field/ EditQuantity.php, line 79
Class
- EditQuantity
- Defines a form element for editing the wishlist item quantity.
Namespace
Drupal\commerce_wishlist\Plugin\views\fieldCode
public function viewsFormSubmit(array &$form, FormStateInterface $form_state) {
$quantities = $form_state
->getValue($this->options['id']);
foreach ($quantities as $row_index => $quantity) {
/** @var \Drupal\commerce_wishlist\Entity\WishlistItemInterface $wishlist_item */
$wishlist_item = $this
->getEntity($this->view->result[$row_index]);
if ($wishlist_item
->getQuantity() != $quantity) {
$wishlist_item
->setQuantity($quantity);
$wishlist_item
->save();
}
}
}