function Htmx::config

Creates a `data-hx-config` attribute.

The hx-config attribute configures behavior of the request.

The hx-config attribute supports the following configuration values:

  • timeout: (integer) Request timeout in milliseconds.
  • credentials: (string) Fetch credentials mode: "omit", "same-origin", "include".
  • cache: (string) Fetch cache mode: "default", "no-cache", "reload", etc.
  • redirect: (string) Fetch redirect mode: "follow", "error", "manual".
  • referrer: (string) Referrer URL or "no-referrer".
  • integrity: (string) Sub-resource integrity value.
  • validate: (boolean) Whether to validate form before submission.

Parameters

array<string, int|bool|string> $configValues: The configuration values as name => value.

int $modifiers: The modifiers to apply to the attribute. Defaults to no modifiers.

Return value

static Returns this object to allow chaining methods.

See also

https://four.htmx.org/reference/attributes/hx-config/

File

core/lib/Drupal/Core/Htmx/Htmx.php, line 1353

Class

Htmx
Presents the HTMX controls for developers to use with render arrays.

Namespace

Drupal\Core\Htmx

Code

public function config(array $configValues, int $modifiers = self::NO_MODIFIER) : static {
  $this->createJsonAttribute('hx-config', $configValues, $modifiers);
  return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.