IncomingRequest
Available methods:
- isHtmx()
- isBoosted()
- isHistoryRestoreRequest()
- getRequestType()
- isPartial()
- isFull()
- getCurrentUrl()
- getPrompt()
- getSource()
- getTarget()
- is()
isHtmx()
Checks if the request carries the HX-Request header with the value true.
$this->request->isHtmx();
isBoosted()
Checks if there is a HX-Boosted header in place.
Indicates that the request is via an element using hx-boost
$this->request->isBoosted();
isHistoryRestoreRequest()
Checks if there is a HX-History-Restore-Request header in place.
True if the request is for history restoration.
$this->request->isHistoryRestoreRequest();
getRequestType()
Checks the HX-Request-Type header.
Returns partial for targeted swaps and full for body-level requests, including hx-boost requests, or requests using hx-select.
$this->request->getRequestType();
isPartial()
Convenience method for checking if HX-Request-Type equals partial.
$this->request->isPartial();
isFull()
Convenience method for checking if HX-Request-Type equals full.
$this->request->isFull();
getCurrentUrl()
Checks the HX-Current-URL header and returns the current URL of the browser.
$this->request->getCurrentUrl();
getPrompt()
Checks the HX-Prompt header sent by the optional htmx 4 hx-prompt extension.
$this->request->getPrompt();
getSource()
Checks the HX-Source header.
In htmx 4 this identifies the triggering element using the element identifier format, for example button#save.
$this->request->getSource();
getTarget()
Checks the HX-Target header.
In htmx 4 it identifies the target element using the element identifier format, for example div#results.
$this->request->getTarget();
is()
This method is available in every CodeIgniter version supported by this package. It is a convenient alternative to getMethod() and also supports other request-type checks. See the CodeIgniter user guide for details.
Along with this library, we added extra parameters that can be used: htmx, boosted, partial, and full.
$this->request->is('htmx');
// or
$this->request->is('boosted');
// or
$this->request->is('partial');
// or
$this->request->is('full');