feat: htmx powered requests, improved loading indicator

feat: loading indicator and htmx form submit
This commit is contained in:
Björn Fromme committed 2026-03-16 11:59:10 +01:00
1 parent 023ecdebc9
commit 83589ee677
20 files changed
+658 -197

No files matched your search

@@ -1,37 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Controller\Traits;
use Symfony\Component\HttpFoundation\Response;
/**
* Provides helper methods for handling HTMX responses.
*
* This trait should be used in controllers that extend Symfony's AbstractController,
* as it relies on the renderBlockView() method.
*/
trait HtmxControllerTrait
{
/**
* Renders multiple Twig blocks for an HTMX Out-of-Band swap response.
*
* @param string $templateName the name of the Twig template
* @param string[] $blockNames an array of block names to render
* @param array<string, mixed> $context the context to pass to the template
*/
protected function htmxOobResponse(string $templateName, array $blockNames, array $context = []): Response
{
$html = '';
// Add a flag to the context so templates can conditionally add the hx-swap-oob attribute.
$oobContext = $context + ['htmx_oob_swap' => true];
foreach ($blockNames as $blockName) {
// Use renderBlockView() to get the raw HTML string for each block.
$html .= $this->renderBlockView($templateName, $blockName, $oobContext);
}
return new Response($html);
}
}