function Htmx::buildRequestAttribute

Utility function for the request attributes.

Provides the logic for the request attribute methods. Separate public methods are maintained for clear correspondence with the attributes of HTMX.

Parameters

string $method: The request method.

\Drupal\Core\Url|null $url: The URL for the request.

Return value

static returns self so that attribute methods may be chained.

5 calls to Htmx::buildRequestAttribute()
Htmx::delete in core/lib/Drupal/Core/Htmx/Htmx.php
Creates a `data-hx-delete` attribute.
Htmx::get in core/lib/Drupal/Core/Htmx/Htmx.php
Creates a `data-hx-get` attribute.
Htmx::patch in core/lib/Drupal/Core/Htmx/Htmx.php
Creates a `data-hx-patch` attribute.
Htmx::post in core/lib/Drupal/Core/Htmx/Htmx.php
Creates a `data-hx-post` attribute.
Htmx::put in core/lib/Drupal/Core/Htmx/Htmx.php
Creates a `data-hx-put` attribute.

File

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

Class

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

Namespace

Drupal\Core\Htmx

Code

protected function buildRequestAttribute(string $method, ?Url $url = NULL) : static {
  if (is_null($url)) {
    $value = '';
  }
  else {
    $value = $this->urlValue($url);
  }
  $this->createStringAttribute($method, $value);
  return $this;
}

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