API Index — Namespaces, Packages, Reports, Indices
ZealJsBinder
extends FormBinder
in package
Components without htmx: a small script (/_zeal/c/zeal.js) that speaks
the plain protocol (Zeal-Request: 1, Zeal-Events, Zeal-Redirect,
Zeal-Reload, 422 for validation).
App::componentBinder(new ZealJsBinder()); // in the layout, once: = ZealJsBinder::script() ?>
Built on FormBinder, so the markup stays a working form without
JavaScript; this binder only adds data-zc-* markers the script reads:
- actions:
data-zc-actionon the element (itsformactionandvaluealready carry the URL and arguments); - live inputs:
data-zc-live(debounce in ms) anddata-zc-update; on-blur inputs:data-zc-bluranddata-zc-update.
The script swaps the re-rendered component in place, keeps the value,
focus and cursor of the field being typed in, lets an action replace a
live update still in flight on the same component, and re-dispatches
Zeal-Events as DOM events (CustomEvent, bubbling, detail set) on
the component.
Table of Contents
Constants
- SCRIPT : mixed = '/_zeal/c/zeal.js'
Properties
- $version : string|null
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.
- script() : SafeHtml
- The script tag for the layout, versioned by the script's content.
- source() : string
- The client script's source, served at {@see self::SCRIPT}.
- triggerField() : string|null
- The name of the form control that triggered the request, if the client reports it.
- version() : string
Constants
SCRIPT
public
mixed
SCRIPT
= '/_zeal/c/zeal.js'
Properties
$version
private
static string|null
$version
= null
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|int, mixed> $server) : bool
Parameters
- $server : array<string|int, 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|int, mixed> $events, string|null $redirect) : array{status: int, headers: array}
Parameters
- $outcome : Outcome
- $events : array<string|int, 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>script()
The script tag for the layout, versioned by the script's content.
public
static script() : SafeHtml
Return values
SafeHtmlsource()
The client script's source, served at {@see self::SCRIPT}.
public
static source() : string
Return values
stringtriggerField()
The name of the form control that triggered the request, if the client reports it.
public
triggerField(array<string|int, mixed> $server) : string|null
Parameters
- $server : array<string|int, mixed>
Return values
string|nullversion()
private
static version() : string