FormTrait
Booking form of step 2: range choice (`timeFrom`/`timeTo` from `starts`) plus contact data.
A honeypot (website) filled by a bot is silently dropped as a success, without calling the Api.
A logged-in user gets name and e-mail prefilled from the JWT identity, with no extra Api call.
IMPORTANT: UserManager::find() (front end) targets :Api:System:User:get, which is admin-only
and would return nothing in enforce mode; findPublicProfile() gives only a masked e-mail,
unusable in a form. The identity carries the raw data from login
(AuthStorageTrait::createIdentity()).
Table of Contents
Constants
- ERROR_MESSAGE_KEYS : array<string|int, mixed> = [ 2 => 'form.messages.errors.validationFailed',...
- `ResultCode->value` (Api) mapped to the translated message key; an unknown code gives the generic message.
Methods
- onBookingFormSuccess() : void
- createComponentBookingForm() : Form
- buildEndOptions() : array<string, string>
- Returns the end offer: the union of reachable ends over all starts, in steps of `slotLengthMinutes`, capped by `maxTo` of the given start. The server validates the concrete `(from, to)` pair again in `book()`; this offer only limits choices to sensible values and is not an authoritative check.
- buildStartOptions() : array<string, string>
- Returns the start offer from `starts` (the offer step, not the grid).
- finishBookingForm() : void
- prefillIdentity() : void
- resolveErrorMessageKey() : string
- An unknown or missing code gives the generic message.
- str() : string
- `ArrayHash` values are `mixed`; safely narrows to string (a non-string becomes empty).
- toMinutes() : int
Constants
ERROR_MESSAGE_KEYS
`ResultCode->value` (Api) mapped to the translated message key; an unknown code gives the generic message.
private
array<string|int, mixed>
ERROR_MESSAGE_KEYS
= [
2 => 'form.messages.errors.validationFailed',
// occupied, in the past or lead time (the Api does not distinguish by code)
4 => 'form.messages.errors.notAvailable',
303 => 'form.messages.errors.dbDuplicateEntry',
304 => 'form.messages.errors.dbLocked',
404 => 'form.messages.errors.rateLimitExceeded',
]
Methods
onBookingFormSuccess()
public
onBookingFormSuccess(Form $form, ArrayHash $values) : void
Parameters
- $form : Form
- $values : ArrayHash
createComponentBookingForm()
protected
createComponentBookingForm() : Form
Return values
FormbuildEndOptions()
Returns the end offer: the union of reachable ends over all starts, in steps of `slotLengthMinutes`, capped by `maxTo` of the given start. The server validates the concrete `(from, to)` pair again in `book()`; this offer only limits choices to sensible values and is not an authoritative check.
private
static buildEndOptions(array<string, mixed>|null $dayData) : array<string, string>
Parameters
- $dayData : array<string, mixed>|null
Return values
array<string, string>buildStartOptions()
Returns the start offer from `starts` (the offer step, not the grid).
private
static buildStartOptions(array<string, mixed>|null $dayData) : array<string, string>
Parameters
- $dayData : array<string, mixed>|null
Return values
array<string, string>finishBookingForm()
private
finishBookingForm(Form $form, bool $success) : void
Parameters
- $form : Form
- $success : bool
prefillIdentity()
private
static prefillIdentity(Form $form, User|null $user) : void
Parameters
- $form : Form
- $user : User|null
resolveErrorMessageKey()
An unknown or missing code gives the generic message.
private
static resolveErrorMessageKey(mixed $code) : string
Parameters
- $code : mixed
Return values
stringstr()
`ArrayHash` values are `mixed`; safely narrows to string (a non-string becomes empty).
private
static str(mixed $value) : string
Parameters
- $value : mixed
Return values
stringtoMinutes()
private
static toMinutes(string $time) : int
Parameters
- $time : string