feat: htmx powered requests, improved loading indicator

feat: loading indicator and htmx form submit
This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 023ecdebc9
commit 83589ee677
20 changed files with 658 additions and 197 deletions
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Htmx;
use Symfony\Component\HttpFoundation\Response;
class HxRedirectResponse extends Response
{
/**
* Creates an HTMX redirect response.
*
* Constructs a response that instructs the HTMX client to navigate to the
* specified URL. The response includes the HX-Redirect header with the target
* URL. Optionally includes HX-Retarget header if a different target element
* is specified for the response content.
*
* @param string $url The URL to redirect to
* @param string|null $retarget Optional CSS selector for the target element
*/
public function __construct(string $url, ?string $retarget = null)
{
$headers = [
'HX-Redirect' => $url,
];
if (null !== $retarget) {
$headers['HX-Retarget'] = $retarget;
}
return parent::__construct(null, Response::HTTP_OK, $headers);
}
}