function Htmx::method
Creates a `data-hx-method` attribute.
The hx-method attribute specifies the HTTP method (verb) to use for the request. It is typically paired with hx-action to separate the URL from the method.
Parameters
string $method: The HTTP method for the request. Accepted values are GET, POST, PUT, PATCH, and DELETE (case-insensitive).
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.
Throws
\ValueError Thrown when the method is not one of the supported values.
See also
https://four.htmx.org/reference/attributes/hx-method/
File
-
core/
lib/ Drupal/ Core/ Htmx/ Htmx.php, line 713
Class
- Htmx
- Presents the HTMX controls for developers to use with render arrays.
Namespace
Drupal\Core\HtmxCode
public function method(string $method, int $modifiers = self::NO_MODIFIER) : static {
if (!in_array(mb_strtolower($method), [
'get',
'post',
'put',
'patch',
'delete',
], TRUE)) {
throw new \ValueError('Invalid value for method');
}
$this->createStringAttribute('hx-method', $method, $modifiers);
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.