SelectRenderer
extends CellRenderer
in package
implements
InlineEditableRenderer
uses
InlineEditableTrait
Renders an inline editable select.
Changing the value sends the inlineUpdate! signal and stores the new property value in the
database via manager->updateColumns() (handled in
HandleTrait). Without an
explicit setUpdateProperty() the column property is updated. The select carries
data-grid-update-url with the __VALUE__ placeholder, which datagrid.js fills in.
Table of Contents
Interfaces
- InlineEditableRenderer
- Renderer whose value can be changed inline from the list: the change sends the signal `inlineUpdate!` and saves the new property value to the database (handled in {@see \App\UI\Admin\System\Components\DataGridComponent\Traits\HandleTrait}).
Properties
- $options : array<int|string, string>
- $updateProperty : string|null
Methods
- __construct() : mixed
- create() : static
- getOptions() : array<int|string, string>
- getTemplateName() : string
- Cell template name (`Cells/<type>.latte`).
- getUpdateProperty() : string
- prepare() : array<string, mixed>
- Variables for the cell template.
- setOptions() : static
- setUpdateProperty() : static
- Property (database column) the new value is saved to.
- toCsvValue() : string
- The `prepare()` vars have no `text` key (a select has `options`/`current`), so the CSV export uses the option label.
- csvOptionLabel() : string
- Label of the current value for the CSV export. {@see SelectRenderer} / {@see ToggleRenderer} have no plain `text` key in the `prepare()` vars (options/current, label/variant for the switch UI), so their `toCsvValue()` uses this instead of the default from {@see CellRenderer}.
- resolveOptionKey() : int|string|null
- Key in options matching the current value (compared as strings because of int vs. string keys), or null when the value is not among the options.
- toScalarValue() : mixed
- Column value to a scalar comparable with the keys of `options` maps: a `BackedEnum` becomes its `value`, a pure enum its `name`, a bool 0/1. Other values pass unchanged.
- toString() : string
- Column value (mixed) to text; non-stringable values give an empty string.
Properties
$options
protected
array<int|string, string>
$options
= []
value => label
$updateProperty
protected
string|null
$updateProperty
= null
Methods
__construct()
public
final __construct() : mixed
create()
public
static create() : static
Return values
staticgetOptions()
public
getOptions() : array<int|string, string>
Return values
array<int|string, string>getTemplateName()
Cell template name (`Cells/<type>.latte`).
public
getTemplateName() : string
Return values
stringgetUpdateProperty()
public
getUpdateProperty(BaseColumn $column) : string
Parameters
- $column : BaseColumn
Return values
stringprepare()
Variables for the cell template.
public
prepare(mixed $value, object $entity, DataGrid $grid, BaseColumn $column) : array<string, mixed>
Parameters
- $value : mixed
- $entity : object
- $grid : DataGrid
- $column : BaseColumn
Return values
array<string, mixed>setOptions()
public
setOptions(array<int|string, string> $options) : static
Parameters
- $options : array<int|string, string>
-
value => label
Return values
staticsetUpdateProperty()
Property (database column) the new value is saved to.
public
setUpdateProperty(string|null $updateProperty) : static
Parameters
- $updateProperty : string|null
Return values
statictoCsvValue()
The `prepare()` vars have no `text` key (a select has `options`/`current`), so the CSV export uses the option label.
public
toCsvValue(mixed $value, object $entity, DataGrid $grid, BaseColumn $column) : string
Parameters
- $value : mixed
- $entity : object
- $grid : DataGrid
- $column : BaseColumn
Return values
stringcsvOptionLabel()
Label of the current value for the CSV export. {@see SelectRenderer} / {@see ToggleRenderer} have no plain `text` key in the `prepare()` vars (options/current, label/variant for the switch UI), so their `toCsvValue()` uses this instead of the default from {@see CellRenderer}.
protected
csvOptionLabel(mixed $value) : string
Parameters
- $value : mixed
Return values
stringresolveOptionKey()
Key in options matching the current value (compared as strings because of int vs. string keys), or null when the value is not among the options.
protected
resolveOptionKey(mixed $value) : int|string|null
Parameters
- $value : mixed
Return values
int|string|nulltoScalarValue()
Column value to a scalar comparable with the keys of `options` maps: a `BackedEnum` becomes its `value`, a pure enum its `name`, a bool 0/1. Other values pass unchanged.
protected
toScalarValue(mixed $value) : mixed
IMPORTANT: entities return an enum object for enum columns (typed property), so without
this normalization the cell template receives an object and (string) $enum is a fatal
error, not an empty output.
Parameters
- $value : mixed
toString()
Column value (mixed) to text; non-stringable values give an empty string.
protected
toString(mixed $value) : string
An enum prints its value/name; a bool keeps the (string) semantics
(false is empty, not "0"), as the admin always printed it.
Parameters
- $value : mixed