Skip to content

Commit e411a77

Browse files
authored
Wrong class used in turbo streams
TurboBundle::STREAM_FORMAT doesn't exist, that static variable was moved to TurboStreamResponse::STREAM_FORMAT. Also the stream didn't work for me unless I changed: $this->render('task/success.stream.html.twig', ['task' => $task]); to $this->render('task/success.stream.html.twig', ['task' => $task], new TurboStreamResponse());
1 parent 18b194b commit e411a77

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Turbo/Resources/doc/index.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ Let's discover how to use Turbo Streams to enhance your `Symfony forms`_::
309309
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
310310
use Symfony\Component\HttpFoundation\Request;
311311
use Symfony\Component\HttpFoundation\Response;
312-
use Symfony\UX\Turbo\TurboBundle;
312+
use Symfony\UX\Turbo\Stream\TurboStreamResponse;
313+
313314
use App\Entity\Task;
314315

315316
class TaskController extends AbstractController
@@ -325,10 +326,10 @@ Let's discover how to use Turbo Streams to enhance your `Symfony forms`_::
325326
// ... perform some action, such as saving the task to the database
326327

327328
// 🔥 The magic happens here! 🔥
328-
if (TurboBundle::STREAM_FORMAT === $request->getPreferredFormat()) {
329+
if (TurboStreamResponse::STREAM_FORMAT === $request->getPreferredFormat()) {
329330
// If the request comes from Turbo, set the content type as text/vnd.turbo-stream.html and only send the HTML to update
330-
$request->setFormat(TurboBundle::STREAM_FORMAT);
331-
return $this->render('task/success.stream.html.twig', ['task' => $task]);
331+
$request->setFormat(TurboStreamResponse::STREAM_FORMAT);
332+
return $this->render('task/success.stream.html.twig', ['task' => $task], new TurboStreamResponse());
332333
}
333334

334335
// If the client doesn't support JavaScript, or isn't using Turbo, the form still works as usual.

0 commit comments

Comments
 (0)