CoolCMS API

FormHelpersTrait

Component counterpart of `AdminFormHelpersTrait`: multilingual form fields and safe conversions of form values.

Unlike the presenter trait it has no #[Inject], which is not filled on components; ShipperTariffEdit receives LanguageManager through its constructor.

Table of Contents

Methods

currentLangId()  : int|null
Returns the current language id (for select captions etc.), null when unknown.
getFormLanguages()  : array<int, Language>
Returns the languages for multilingual form fields (admin `LanguageManager`, constructor-injected).
intOrNull()  : int|null
Converts a mixed form value to an int or null (an empty or zero value becomes null).
str()  : string
Converts a mixed form value to a string; non-scalars become an empty string.
strOrNull()  : string|null
Converts a mixed form value to a string or null (an empty string is stored as null).

Methods

currentLangId()

Returns the current language id (for select captions etc.), null when unknown.

protected currentLangId() : int|null
Return values
int|null

getFormLanguages()

Returns the languages for multilingual form fields (admin `LanguageManager`, constructor-injected).

protected getFormLanguages() : array<int, Language>
Return values
array<int, Language>

intOrNull()

Converts a mixed form value to an int or null (an empty or zero value becomes null).

protected intOrNull(mixed $value) : int|null
Parameters
$value : mixed
Return values
int|null

str()

Converts a mixed form value to a string; non-scalars become an empty string.

protected str(mixed $value) : string
Parameters
$value : mixed
Return values
string

strOrNull()

Converts a mixed form value to a string or null (an empty string is stored as null).

protected strOrNull(mixed $value) : string|null
Parameters
$value : mixed
Return values
string|null
On this page

Search results