Skip to content

Commit 23ef0d2

Browse files
author
romain
committed
fix rst formating
1 parent b2625dd commit 23ef0d2

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

doc/index.rst

+23-23
Original file line numberDiff line numberDiff line change
@@ -1329,40 +1329,40 @@ The files will be available in a regular ``$request->files`` files bag::
13291329
.. _downloads:
13301330

13311331
Downloading files
1332-
-----------------------
1332+
-----------------
13331333

13341334
Currently, Live Components do not natively support returning file responses directly from a LiveAction. However, you can implement file downloads by redirecting to a route that handles the file response.
13351335

13361336
Create a LiveAction that generates the URL for the file download and returns a `RedirectResponse`::
13371337

1338-
use Symfony\Component\HttpFoundation\RedirectResponse;
1339-
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1340-
use Symfony\UX\LiveComponent\Attribute\LiveAction;
1338+
use Symfony\Component\HttpFoundation\RedirectResponse;
1339+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1340+
use Symfony\UX\LiveComponent\Attribute\LiveAction;
13411341

1342-
// ...
1342+
// ...
13431343

1344-
class MyDownloadButton
1345-
{
1346-
// ...
1344+
class MyDownloadButton
1345+
{
1346+
// ...
13471347

1348-
#[LiveAction]
1349-
public function initiateDownload(UrlGeneratorInterface $urlGenerator): RedirectResponse
1350-
{
1351-
$url = $urlGenerator->generate('app_file_download');
1352-
return new RedirectResponse($url);
1353-
}
1354-
}
1348+
#[LiveAction]
1349+
public function initiateDownload(UrlGeneratorInterface $urlGenerator): RedirectResponse
1350+
{
1351+
$url = $urlGenerator->generate('app_file_download');
1352+
return new RedirectResponse($url);
1353+
}
1354+
}
13551355

13561356
.. code-block:: html+twig
13571357

1358-
<div {{ attributes }} data-turbo="false">
1359-
<button
1360-
data-action="live#action"
1361-
data-live-action-param="initiateDownload"
1362-
>
1363-
Download
1364-
</button>
1365-
</div>
1358+
<div {{ attributes }} data-turbo="false">
1359+
<button
1360+
data-action="live#action"
1361+
data-live-action-param="initiateDownload"
1362+
>
1363+
Download
1364+
</button>
1365+
</div>
13661366

13671367
When Turbo is enabled, it will intercept the redirect and initiate a second request for the download URL. Adding `data-turbo="false"` ensures that the download URL is called only once.
13681368

0 commit comments

Comments
 (0)