DataListHelper
in package
FinalYes
Helper for preparing data arrays for selects and similar form controls.
Table of Contents
Methods
- prepare() : array<string|int, mixed>
- Prepares an associative array from a list of items.
Methods
prepare()
Prepares an associative array from a list of items.
public
static prepare(iterable<string|int, T> $items, callable(T): Array $idFn, callable(T): string $nameFn[, string|null $suffix = null ]) : array<string|int, mixed>
Parameters
- $items : iterable<string|int, T>
-
The items to transform
- $idFn : callable(T): Array
-
Callback to get the key (id) from an item; null (unsaved item) is skipped
- $nameFn : callable(T): string
-
Callback to get the label from an item
- $suffix : string|null = null
-
Optional suffix to append to each label