protected function WishlistItemDetailsForm::successfulAjaxSubmit in Commerce Wishlist 8.3
Allows the form to respond to a successful AJAX submission.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
\Drupal\Core\Ajax\AjaxResponse An AJAX response.
Overrides AjaxFormHelperTrait::successfulAjaxSubmit
File
- src/
Form/ WishlistItemDetailsForm.php, line 85
Class
- WishlistItemDetailsForm
- Provides the wishlist details form.
Namespace
Drupal\commerce_wishlist\FormCode
protected function successfulAjaxSubmit(array $form, FormStateInterface $form_state) {
// We need to clear parent wishlist cache, so that on refresh
// we are able to see changes also, not only after ajax updates.
$wishlist = $this->entity
->getWishlist();
Cache::invalidateTags($wishlist
->getCacheTags());
$response = new AjaxResponse();
$response
->addCommand(new PrependCommand('.commerce-wishlist-form', [
'#type' => 'status_messages',
]));
$response
->addCommand(new ReplaceCommand('#wishlist-item-details-' . $this->entity
->id(), [
'#theme' => 'commerce_wishlist_item_details',
'#wishlist_item_entity' => $this->entity,
]));
$response
->addCommand(new CloseDialogCommand());
return $response;
}