Generator
in package
Compile form structures, bind values and render forms or lists.
Table of Contents
Constants
- ACTIONS : mixed = ['move-up', 'move-down', 'add-row', 'copy-row',...
- The operations that an action button can request (CURT-081).
Methods
- bindButtons() : array<string|int, mixed>
- Evaluate the template buttons for a record as objects with type, tag, text and ordered attrs.
- bindForm() : array<string|int, mixed>
- Evaluate fields without modifying template or record data. The option `collapsed` lists the row paths `{collection}.{key}` rendered collapsed.
- buildDetail() : stdClass
- Build one read-only detail model from a supplied record.
- buildList() : stdClass
- Build one read-only list model from supplied rows.
- buildOutline() : array<int, stdClass>
- Build the structure map of evaluated nodes: the rows of the form, each with the rows nested in it and the row controls placed in the map (`multiple.controls: outline`).
- canRedo() : bool
- Return whether an undone change can be reapplied (CURT-078).
- canUndo() : bool
- Return whether a record can be restored (CURT-078).
- collapsibleRows() : array<int, string>
- The row paths `{collection}.{key}` of every collapsible row of the evaluated nodes.
- compileForm() : stdClass
- Compile a JSON-serializable structure without record data.
- createRowKey() : string
- Generate a thirteen-character hexadecimal row key.
- emptyHistory() : stdClass
- Return the history with no record (CURT-076).
- formButtonsHtml() : string
- Render evaluated buttons as the markup every renderer places in the form footer; reject any other element.
- initialView() : array<string|int, mixed>
- The view with no collapsed row; a view is `['collapsed' => list of row paths]`.
- recordChange() : stdClass
- Return the history after a change from the previous record, with at most 100 records in each direction (CURT-077).
- redoChange() : stdClass
- Return the history and the record after the last undone change; fail when there is none (CURT-080).
- rekeyRowView() : array<string|int, mixed>
- Move the collapsed state of a rekeyed row and of the rows inside it to the new row path.
- removeRowView() : array<string|int, mixed>
- Drop the collapsed state of a removed row and of the rows inside it.
- renderDetail() : string
- Render one read-only detail from a supplied record.
- renderForm() : string
- Render the current instance as the complete form (form-runtime.md, "Complete form").
- renderList() : string
- Render supplied list rows using the table or card layout.
- resolveAction() : stdClass|null
- Resolve the target of an action button from the values it declares (CURT-081): `action`, the collection `path` and the row `key`. An action that is none of the eleven resolves to null; an empty path or key is left out.
- runAction() : stdClass|null
- Run a resolved action on the form (CURT-082 to CURT-090) and return its result: `focus` names the row or the collection that receives focus, and an action that moves no focus returns an empty result. A target without the path or the key that the action needs returns null and changes nothing. A failing operation throws its FormError and leaves the form unchanged.
- sequenceRowKey() : string
- Format a nonnegative sequence with thirteen decimal digits.
- setAllExpandedView() : array<string|int, mixed>
- The view with no collapsed row, or the view that collapses every collapsible row of the nodes.
- toggleRowView() : array<string|int, mixed>
- Expand a collapsed row or collapse an expanded one.
- undoChange() : stdClass
- Return the history and the record before the last change; fail when there is none (CURT-079).
- actionText() : string|null
- The text of an action value: null when absent; a value that is no string is an invalid input.
- checkDisplay() : void
- Input text of a list or detail operation: the specification, the files, the rows or record, then the display options. A value that is no object or array has no text to check here; its shape fails in the operation, in argument order.
- focus() : stdClass
- The result of an action that moves the focus to a row, or to the collection when the key is null.
- rowKeys() : array<string|int, mixed>
- The row keys of the collection at `$path` in order; a value that is no keyed object has none.
Constants
ACTIONS
The operations that an action button can request (CURT-081).
private
mixed
ACTIONS
= ['move-up', 'move-down', 'add-row', 'copy-row', 'remove-row', 'toggle-row', 'select-row', 'expand-all', 'collapse-all', 'undo', 'redo']
Methods
bindButtons()
Evaluate the template buttons for a record as objects with type, tag, text and ordered attrs.
public
static bindButtons(stdClass $template[, mixed $data = [] ][, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $template : stdClass
- $data : mixed = []
- $options : array<string|int, mixed> = []
Return values
array<string|int, mixed>bindForm()
Evaluate fields without modifying template or record data. The option `collapsed` lists the row paths `{collection}.{key}` rendered collapsed.
public
static bindForm(stdClass $template[, mixed $data = [] ][, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $template : stdClass
- $data : mixed = []
- $options : array<string|int, mixed> = []
Return values
array<string|int, mixed>buildDetail()
Build one read-only detail model from a supplied record.
public
static buildDetail(mixed $spec[, mixed $record = new stdClass() ][, array<string|int, mixed> $options = [] ]) : stdClass
Parameters
- $spec : mixed
- $record : mixed = new stdClass()
- $options : array<string|int, mixed> = []
Return values
stdClassbuildList()
Build one read-only list model from supplied rows.
public
static buildList(mixed $spec[, mixed $rows = [] ][, array<string|int, mixed> $options = [] ]) : stdClass
Parameters
- $spec : mixed
- $rows : mixed = []
- $options : array<string|int, mixed> = []
Return values
stdClassbuildOutline()
Build the structure map of evaluated nodes: the rows of the form, each with the rows nested in it and the row controls placed in the map (`multiple.controls: outline`).
public
static buildOutline(array<int, stdClass> $nodes) : array<int, stdClass>
Parameters
- $nodes : array<int, stdClass>
-
the evaluated nodes that bindForm returns
Return values
array<int, stdClass>canRedo()
Return whether an undone change can be reapplied (CURT-078).
public
static canRedo(stdClass $history) : bool
Parameters
- $history : stdClass
Return values
boolcanUndo()
Return whether a record can be restored (CURT-078).
public
static canUndo(stdClass $history) : bool
Parameters
- $history : stdClass
Return values
boolcollapsibleRows()
The row paths `{collection}.{key}` of every collapsible row of the evaluated nodes.
public
static collapsibleRows(array<int, stdClass> $nodes) : array<int, string>
Parameters
- $nodes : array<int, stdClass>
-
the evaluated nodes that bindForm returns
Return values
array<int, string>compileForm()
Compile a JSON-serializable structure without record data.
public
static compileForm(array<string|int, mixed>|stdClass $spec[, array<string|int, mixed> $options = [] ]) : stdClass
Parameters
- $spec : array<string|int, mixed>|stdClass
- $options : array<string|int, mixed> = []
Return values
stdClasscreateRowKey()
Generate a thirteen-character hexadecimal row key.
public
static createRowKey() : string
Return values
stringemptyHistory()
Return the history with no record (CURT-076).
public
static emptyHistory() : stdClass
Return values
stdClassformButtonsHtml()
Render evaluated buttons as the markup every renderer places in the form footer; reject any other element.
public
static formButtonsHtml(mixed $buttons) : string
Parameters
- $buttons : mixed
Return values
stringinitialView()
The view with no collapsed row; a view is `['collapsed' => list of row paths]`.
public
static initialView() : array<string|int, mixed>
Return values
array<string|int, mixed>recordChange()
Return the history after a change from the previous record, with at most 100 records in each direction (CURT-077).
public
static recordChange(stdClass $history, mixed $previous[, string|null $path = null ]) : stdClass
Parameters
- $history : stdClass
- $previous : mixed
- $path : string|null = null
Return values
stdClassredoChange()
Return the history and the record after the last undone change; fail when there is none (CURT-080).
public
static redoChange(stdClass $history, mixed $current) : stdClass
Parameters
- $history : stdClass
- $current : mixed
Return values
stdClassrekeyRowView()
Move the collapsed state of a rekeyed row and of the rows inside it to the new row path.
public
static rekeyRowView(array<string|int, mixed> $view, string $oldPath, string $newPath) : array<string|int, mixed>
Parameters
- $view : array<string|int, mixed>
- $oldPath : string
- $newPath : string
Return values
array<string|int, mixed>removeRowView()
Drop the collapsed state of a removed row and of the rows inside it.
public
static removeRowView(array<string|int, mixed> $view, string $rowPath) : array<string|int, mixed>
Parameters
- $view : array<string|int, mixed>
- $rowPath : string
Return values
array<string|int, mixed>renderDetail()
Render one read-only detail from a supplied record.
public
static renderDetail(mixed $spec[, mixed $record = new stdClass() ][, array<string|int, mixed> $options = [] ]) : string
Parameters
- $spec : mixed
- $record : mixed = new stdClass()
- $options : array<string|int, mixed> = []
Return values
stringrenderForm()
Render the current instance as the complete form (form-runtime.md, "Complete form").
public
static renderForm(Form $form[, mixed $options = [] ]) : string
Parameters
- $form : Form
- $options : mixed = []
-
an object with optional action, hidden, formErrors and errors members
Tags
Return values
stringrenderList()
Render supplied list rows using the table or card layout.
public
static renderList(mixed $spec, mixed $rows[, array<string|int, mixed> $options = [] ]) : string
Parameters
- $spec : mixed
- $rows : mixed
- $options : array<string|int, mixed> = []
Return values
stringresolveAction()
Resolve the target of an action button from the values it declares (CURT-081): `action`, the collection `path` and the row `key`. An action that is none of the eleven resolves to null; an empty path or key is left out.
public
static resolveAction(array{action?: mixed, path?: mixed, key?: mixed}|stdClass $input) : stdClass|null
Parameters
- $input : array{action?: mixed, path?: mixed, key?: mixed}|stdClass
Return values
stdClass|nullrunAction()
Run a resolved action on the form (CURT-082 to CURT-090) and return its result: `focus` names the row or the collection that receives focus, and an action that moves no focus returns an empty result. A target without the path or the key that the action needs returns null and changes nothing. A failing operation throws its FormError and leaves the form unchanged.
public
static runAction(Form $form, array{name?: mixed, path?: mixed, key?: mixed}|stdClass $target) : stdClass|null
Parameters
- $form : Form
- $target : array{name?: mixed, path?: mixed, key?: mixed}|stdClass
Return values
stdClass|nullsequenceRowKey()
Format a nonnegative sequence with thirteen decimal digits.
public
static sequenceRowKey(int|string $sequence) : string
Parameters
- $sequence : int|string
Return values
stringsetAllExpandedView()
The view with no collapsed row, or the view that collapses every collapsible row of the nodes.
public
static setAllExpandedView(array<int, stdClass> $nodes, bool $expanded) : array<string|int, mixed>
Parameters
- $nodes : array<int, stdClass>
-
the evaluated nodes that bindForm returns
- $expanded : bool
Return values
array<string|int, mixed>toggleRowView()
Expand a collapsed row or collapse an expanded one.
public
static toggleRowView(array<string|int, mixed> $view, string $rowPath) : array<string|int, mixed>
Parameters
- $view : array<string|int, mixed>
- $rowPath : string
Return values
array<string|int, mixed>undoChange()
Return the history and the record before the last change; fail when there is none (CURT-079).
public
static undoChange(stdClass $history, mixed $current) : stdClass
Parameters
- $history : stdClass
- $current : mixed
Return values
stdClassactionText()
The text of an action value: null when absent; a value that is no string is an invalid input.
private
static actionText(array<string|int, mixed> $values, string $member) : string|null
Parameters
- $values : array<string|int, mixed>
- $member : string
Return values
string|nullcheckDisplay()
Input text of a list or detail operation: the specification, the files, the rows or record, then the display options. A value that is no object or array has no text to check here; its shape fails in the operation, in argument order.
private
static checkDisplay(mixed $spec, array{0: string, 1: mixed} $input, array<string|int, mixed> $options) : void
Parameters
- $spec : mixed
- $input : array{0: string, 1: mixed}
- $options : array<string|int, mixed>
focus()
The result of an action that moves the focus to a row, or to the collection when the key is null.
private
static focus(string $path[, string|null $key = null ]) : stdClass
Parameters
- $path : string
- $key : string|null = null
Return values
stdClassrowKeys()
The row keys of the collection at `$path` in order; a value that is no keyed object has none.
private
static rowKeys(Form $form, string $path) : array<string|int, mixed>
Parameters
- $form : Form
- $path : string