API Index — Namespaces, Packages, Reports, Indices
ComponentBinder
in
Decides which HTML attributes make a component interactive in the browser, and how endpoint side effects (events, redirects, reloads) are signalled.
The component endpoint itself speaks a plain-HTTP protocol (see
docs/components.md#protocol); a binder adapts the markup and response
headers to one client: htmx (HtmxBinder, the default), no JavaScript
(FormBinder), or a custom one.
Every binder must keep the no-JS fallback working: attributes it returns are added on top of the plain-form markup from FormBinder.
Table of Contents
Methods
- actionAttributes() : array<string, string|bool|null>
- Attributes for an element that triggers an action.
- isAsync() : bool
- Whether the request came from this binder's client script (rather than a plain form post that expects a redirect back to the page).
- modelAttributes() : array<string, string|bool|null>
- Attributes for a form control bound to a
#[Model]property. - refusalHeaders() : array<string, string>
- Extra headers for a refused request (400/403/404), e.g. telling the client not to swap the error text into the page.
-
response()
: array{status: int, headers: array
} - Status and headers for an endpoint outcome.
- rootAttributes() : array<string, string|bool|null>
- Extra attributes for the component's outer element.
- triggerField() : string|null
- The name of the form control that triggered the request, if the client reports it.
Methods
actionAttributes()
Attributes for an element that triggers an action.
public
actionAttributes(Component $component, string $url, string $argsJson) : array<string, string|bool|null>
Parameters
- $component : Component
- $url : string
- $argsJson : string
-
the action arguments, JSON-encoded
Return values
array<string, string|bool|null>isAsync()
Whether the request came from this binder's client script (rather than a plain form post that expects a redirect back to the page).
public
isAsync(array<string, mixed> $server) : bool
Parameters
- $server : array<string, mixed>
-
CGI-style request variables (
HTTP_*)
Return values
boolmodelAttributes()
Attributes for a form control bound to a #[Model] property.
public
modelAttributes(Component $component, string $prop, Model $model, string $updateUrl, bool $preserve) : array<string, string|bool|null>
Parameters
- $component : Component
- $prop : string
- $model : Model
- $updateUrl : string
-
the component's
_updateendpoint - $preserve : bool
-
true when this control triggered the current update and should be left untouched by the swap
Return values
array<string, string|bool|null>refusalHeaders()
Extra headers for a refused request (400/403/404), e.g. telling the client not to swap the error text into the page.
public
refusalHeaders() : array<string, string>
Return values
array<string, string>response()
Status and headers for an endpoint outcome.
public
response(Outcome $outcome, array<string, mixed> $events, string|null $redirect) : array{status: int, headers: array}
Parameters
- $outcome : Outcome
- $events : array<string, mixed>
-
event name → detail
- $redirect : string|null
Return values
array{status: int, headers: arrayrootAttributes()
Extra attributes for the component's outer element.
public
rootAttributes(Component $component, string|null $submitUrl) : array<string, string|bool|null>
Parameters
- $component : Component
- $submitUrl : string|null
-
the URL of the component's
$submitaction, if any
Return values
array<string, string|bool|null>triggerField()
The name of the form control that triggered the request, if the client reports it.
public
triggerField(array<string, mixed> $server) : string|null
Parameters
- $server : array<string, mixed>