feat: htmx powered requests, improved loading indicator
feat: loading indicator and htmx form submit
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user