forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamcleanup-stream-append-review.diff
29 lines (28 loc) · 1.21 KB
/
streamcleanup-stream-append-review.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
diff --git a/src/Controller/ProductController.php b/src/Controller/ProductController.php
index 309e18f..4fe5bf5 100644
--- a/src/Controller/ProductController.php
+++ b/src/Controller/ProductController.php
@@ -93,6 +93,7 @@ class ProductController extends AbstractController
'product-reviews',
$this->renderView('product/reviews.stream.html.twig', [
'product' => $product,
+ 'newReview' => $reviewForm->getData(),
]),
);
$mercureHub->publish($update);
diff --git a/templates/product/reviews.stream.html.twig b/templates/product/reviews.stream.html.twig
index a1321d5..d1d0b96 100644
--- a/templates/product/reviews.stream.html.twig
+++ b/templates/product/reviews.stream.html.twig
@@ -4,8 +4,10 @@
</template>
</turbo-stream>
-<turbo-stream action="replace" target="product-{{ product.id }}-review-list">
+<turbo-stream action="append" target="product-{{ product.id }}-review-list">
<template>
- {{ include('product/_reviews_list.html.twig') }}
+ {{ include('product/_review.html.twig', {
+ review: newReview,
+ }) }}
</template>
</turbo-stream>