CoolCMS API

FormHelpersTrait

Component counterpart of `App\Core\Traits\Admin\Presenters\AdminFormHelpersTrait`.

Same implementations (multilingual fields, safe ArrayHash conversions), but without the presenter #[Inject], which is not filled on a component: ProductSetEdit receives LanguageManager through its constructor. getLanguageContext() is nullsafe because the component context may not be attached yet when called (on a presenter it is always set).

Table of Contents

Methods

currentLangId()  : int|null
Returns the current language id (for picker captions etc.), or null when unknown or not attached.
getFormLanguages()  : array<int, Language>
Returns the languages for multilingual form fields (admin `LanguageManager`, constructor-injected).
intOrNull()  : int|null
Converts a mixed value to an int or null (an empty or zero value becomes null).
parseDateTime()  : DateTime|null
Parses a `datetime-local` input or text value into a `DateTime`, or null when empty or invalid.
str()  : string
Converts a mixed form value to a string safely.
strOrNull()  : string|null
Converts a mixed value to a string or null (an empty string is stored as null).

Methods

currentLangId()

Returns the current language id (for picker captions etc.), or null when unknown or not attached.

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 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

parseDateTime()

Parses a `datetime-local` input or text value into a `DateTime`, or null when empty or invalid.

protected parseDateTime(mixed $value) : DateTime|null
Parameters
$value : mixed
Return values
DateTime|null

str()

Converts a mixed form value to a string safely.

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

strOrNull()

Converts a mixed 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