ApiClientFormTrait
Form of one external Api client (`Admin:System:ApiClient`, add/edit).
Fields: name (required), note, four limits (integer >= 1, empty = default from
api.clientKey.limits, shown in the placeholder and hint) and allowed roles (checkboxes, default
roles prefilled for a new client; privileged roles carry a warning in the template).
IMPORTANT: update replaces the limits as a whole, so the payload always carries all four limits
and roleIds (ApiClientFormPayload); an omitted limit would fall back to the default.
IMPORTANT: after creation the readable key is handed over once to the list (ApiClientKeyHandover)
and the redirect always goes to the list, never back to the Referer page; elsewhere the key
would not be shown and would be lost.
Roles use setTranslator(null) with a ready label because role names are data (from the
database), not keys.
A new client also gets a "first key" section (label and expiry,
ApiClientKeyFormTrait::addApiClientKeyFields()); editing does not have it, keys are
managed on their own page (keys).
Table of Contents
Methods
- createComponentEditForm() : Form
- reportApiClientFormError() : void
- Reports an Api error: `VALIDATION_FAILED` goes to the field named by `data.field`, others as a flash message.
- requiredRoleIds() : array<int, int>
- saveApiClientForm() : bool
- setApiClientFormDefaults() : void
Methods
createComponentEditForm()
protected
createComponentEditForm() : Form
Return values
FormreportApiClientFormError()
Reports an Api error: `VALIDATION_FAILED` goes to the field named by `data.field`, others as a flash message.
private
reportApiClientFormError(Result $result, Form $form) : void
Parameters
requiredRoleIds()
private
requiredRoleIds() : array<int, int>
Return values
array<int, int> —required client roles (guest), checked and disabled
saveApiClientForm()
private
saveApiClientForm(ArrayHash<string|int, mixed> $values, Form $form) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
- $form : Form
Return values
boolsetApiClientFormDefaults()
private
setApiClientFormDefaults(Form $form) : void
Parameters
- $form : Form