function Htmx::action

Creates a `data-hx-action` attribute.

The hx-action attribute specifies the URL that will receive the request. It mirrors the native action attribute on forms, making it familiar to HTML authors and enabling progressive enhancement.

This method also accepts no parameters, which sets the action to the current url. If parameters are used, both are required.

Parameters

\Drupal\Core\Url|null $url: The URL for the action. If NULL, the current page is used without the query parameters.

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

Return value

static Returns self so that attribute methods may be chained.

See also

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

File

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

Class

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

Namespace

Drupal\Core\Htmx

Code

public function action(?Url $url = NULL, int $modifiers = self::NO_MODIFIER) : static {
  return $this->buildRequestAttribute('hx-action', $url, $modifiers);
}

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