AdminFormHelpersTrait
Shared helpers of admin edit forms: multilingual fields and safe conversions of values from `ArrayHash`. Used next to the form trait so `getFormLanguages()`, `str()` and `parseDateTime()` are not duplicated per presenter.
LanguageManager is injected with #[Inject] (like AdminEditFormComponentsTrait),
so the presenter does not take it in the constructor, and the property name differs from
the Front $languageManager, so they cannot collide. IMPORTANT: do not combine the trait
with a constructor-promoted adminLanguageManager; the duplicate property is a fatal error.
Table of Contents
Properties
Methods
- currentLangId() : int|null
- Returns the current language id (for picker labels etc.), null when unknown.
- getFormLanguages() : array<int, Language>
- Returns the languages for multilingual form fields (admin `LanguageManager`).
- intOrNull() : int|null
- Converts mixed to int or null (an empty or zero value becomes null).
- parseDateTime() : DateTime|null
- Converts a `datetime-local` input or text value to `DateTime`, or null when empty or unparsable.
- str() : string
- Safely converts a mixed form value to string.
- strOrNull() : string|null
- Converts mixed to string or null (an empty string is stored as null).
Properties
$adminLanguageManager
public
LanguageManager
$adminLanguageManager
Attributes
- #[Inject]
Methods
currentLangId()
Returns the current language id (for picker labels etc.), null when unknown.
protected
currentLangId() : int|null
Return values
int|nullgetFormLanguages()
Returns the languages for multilingual form fields (admin `LanguageManager`).
protected
getFormLanguages() : array<int, Language>
Return values
array<int, Language>intOrNull()
Converts mixed to int or null (an empty or zero value becomes null).
protected
intOrNull(mixed $value) : int|null
Parameters
- $value : mixed
Return values
int|nullparseDateTime()
Converts a `datetime-local` input or text value to `DateTime`, or null when empty or unparsable.
protected
parseDateTime(mixed $value) : DateTime|null
Parameters
- $value : mixed
Return values
DateTime|nullstr()
Safely converts a mixed form value to string.
protected
str(mixed $value) : string
Parameters
- $value : mixed
Return values
stringstrOrNull()
Converts mixed to string or null (an empty string is stored as null).
protected
strOrNull(mixed $value) : string|null
Parameters
- $value : mixed