CoolCMS API

FormTrait

Booking form in the modal: recap of the tapped slot, refinement of the time (`timeFrom`/`timeTo` prefilled from the slot, capped by `maxTo`), optional subject, note and contact data.

IMPORTANT: the time offer is not authoritative. The server validates the (from, to) pair again in book(); the front end only limits it to sensible values and duplicates no server logic.

The honeypot website and gdprConsent behave as in FormTrait (a filled honeypot is silently dropped as a success, without calling the Api).

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.

Properties

$bookingMessage  : string|null
Message printed inside the modal (not through the session flash, which would duplicate the inline output on the page).
$bookingMessageType  : string

Methods

onBookingFormError()  : void
Validation errors (missing consent, empty name...); the modal stays open with the form.
onBookingFormSuccess()  : void
createComponentBookingForm()  : Form
buildEndOptions()  : array<string, string>
Returns the ends: the union of reachable ends over all starts of the day, in steps of `slotLengthMinutes`, capped by `maxTo`. Not authoritative; the server verifies the pair again.
buildStartOptions()  : array<string, string>
Returns the starts: the server-trimmed `starts` of the chosen day ({@see InitTrait::bookableStarts()}).
finishBooking()  : void
Success (also the silent honeypot one); the message stays in the modal and the calendar below is redrawn.
formatTime()  : string
Minutes since midnight to `HH:MM` (the end offer must match `starts` in shape, i.e. with a leading zero).
prefillIdentity()  : void
prepareFormTemplate()  : void
Recap data and messages for `Sections/Form.latte`.
refreshWizardAfterBooking()  : void
Second snippet next to the modal: in inline mode the redrawn calendar on the booking page, in modal mode the client's reservation list on the "my time slots" page (a new one was added).
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 4 => 'form.messages.errors.notAvailable', 303 => 'form.messages.errors.dbDuplicateEntry', 304 => 'form.messages.errors.dbLocked', 404 => 'form.messages.errors.rateLimitExceeded', ]

Properties

$bookingMessage

Message printed inside the modal (not through the session flash, which would duplicate the inline output on the page).

private string|null $bookingMessage = null

$bookingMessageType

private string $bookingMessageType = 'alert-info'

Methods

onBookingFormError()

Validation errors (missing consent, empty name...); the modal stays open with the form.

public onBookingFormError(Form $form) : void
Parameters
$form : Form

onBookingFormSuccess()

public onBookingFormSuccess(Form $form, ArrayHash $values) : void
Parameters
$form : Form
$values : ArrayHash

createComponentBookingForm()

protected createComponentBookingForm() : Form
Return values
Form

buildEndOptions()

Returns the ends: the union of reachable ends over all starts of the day, in steps of `slotLengthMinutes`, capped by `maxTo`. Not authoritative; the server verifies the pair again.

private buildEndOptions() : array<string, string>
Return values
array<string, string>

buildStartOptions()

Returns the starts: the server-trimmed `starts` of the chosen day ({@see InitTrait::bookableStarts()}).

private buildStartOptions() : array<string, string>
Return values
array<string, string>

finishBooking()

Success (also the silent honeypot one); the message stays in the modal and the calendar below is redrawn.

private finishBooking(string $messageKey, string $type) : void
Parameters
$messageKey : string
$type : string

formatTime()

Minutes since midnight to `HH:MM` (the end offer must match `starts` in shape, i.e. with a leading zero).

private static formatTime(int $minutes) : string
Parameters
$minutes : int
Return values
string

prefillIdentity()

private static prefillIdentity(Form $form, User|null $user) : void
Parameters
$form : Form
$user : User|null

prepareFormTemplate()

Recap data and messages for `Sections/Form.latte`.

private prepareFormTemplate() : void

refreshWizardAfterBooking()

Second snippet next to the modal: in inline mode the redrawn calendar on the booking page, in modal mode the client's reservation list on the "my time slots" page (a new one was added).

private refreshWizardAfterBooking() : void

resolveErrorMessageKey()

An unknown or missing code gives the generic message.

private static resolveErrorMessageKey(mixed $code) : string
Parameters
$code : mixed
Return values
string

str()

`ArrayHash` values are `mixed`; safely narrows to string (a non-string becomes empty).

private static str(mixed $value) : string
Parameters
$value : mixed
Return values
string

toMinutes()

private static toMinutes(string $time) : int
Parameters
$time : string
Return values
int
On this page

Search results