function Htmx::replaceUrl
Creates a `data-hx-replace-url` attribute.
This attribute instructs HTMX to control URLs in the browser location bar.
Use a boolean when this attribute is added along with a request:
- true: replaces the fetched URL in the browser navigation bar.
- false: disables replacing the fetched URL if it would otherwise be replaced due to inheritance.
Use a URL to replace the value in the location bar. This may be relative or absolute, as per history.replaceState().
Parameters
bool|\Drupal\Core\Url $value: A Url object, or a boolean, depending on the use case. See details above.
Return value
static Returns this object to allow chaining methods.
See also
https://htmx.org/attributes/hx-replace-url/
File
-
core/
lib/ Drupal/ Core/ Htmx/ Htmx.php, line 1186
Class
- Htmx
- Presents the HTMX controls for developers to use with render arrays.
Namespace
Drupal\Core\HtmxCode
public function replaceUrl(bool|Url $value) : static {
$url = $value ? 'true' : 'false';
if ($value instanceof Url) {
$url = $this->urlValue($value);
}
$this->createStringAttribute('hx-replace-url', $url);
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.