CoolCMS API

ParameterOptionsTrait

Options editor of a parameter: one flat multiplier `options`.

Each option is a child parameter (level = 2). A row carries a stable optionId, the active toggle, name and label per language, and the "default" / "default in search" flags. Order is the DOM order (SortableJS reorders the rows, so the form submits them in the right order). Add/remove are ajax and redraw the options snippet.

Saving goes through buildOptionsMeta() into meta['options'] and the Api OptionsSyncTrait (id-stable upsert + nested-set gate). The editor renders on edit only: a new parameter has no lft/rgt yet, so options cannot be attached to it. Shared by Bazaar, Comcat and Eshop; see ParameterFormTrait for the class-string getter pattern.

Table of Contents

Properties

$editedParameterOptionsCache  : array<int, BaseEntity|ParameterInterface>|null

Methods

parameterEntityClass()  : string
parameterManager()  : Manager
parameterTextEntityClass()  : string
addOptionFields()  : void
Options section: flat multiplier of options (child parameters).
addOptionRowControls()  : void
Adds the fields of one option row: stable id, active flag, name and label per language, default flags.
applyOptionsDefaults()  : void
Prefills the options editor on GET from the child parameters of the edited parameter.
buildOptionsMeta()  : array<int, array{optionId: int, active: bool, default: bool, searchDefault: bool, texts: array}>
Builds `meta['options']` from the multiplier values as flat options for the Api sync.
editedParameterOptions()  : array<int, BaseEntity|ParameterInterface>
Returns the options (child parameters) of the edited parameter, with translations, ordered by `lft`.
optionRowField()  : mixed
optionRowInt()  : int

Properties

Methods

parameterEntityClass()

protected abstract parameterEntityClass() : string
Return values
string

parameterTextEntityClass()

protected abstract parameterTextEntityClass() : string
Return values
string

addOptionFields()

Options section: flat multiplier of options (child parameters).

private addOptionFields(Form $form) : void
Parameters
$form : Form

addOptionRowControls()

Adds the fields of one option row: stable id, active flag, name and label per language, default flags.

private addOptionRowControls(Container $container) : void
Parameters
$container : Container

applyOptionsDefaults()

Prefills the options editor on GET from the child parameters of the edited parameter.

private applyOptionsDefaults(Form $form) : void
Parameters
$form : Form

buildOptionsMeta()

Builds `meta['options']` from the multiplier values as flat options for the Api sync.

private buildOptionsMeta(ArrayHash<string|int, mixed> $values) : array<int, array{optionId: int, active: bool, default: bool, searchDefault: bool, texts: array}>

Order is the order of the submitted rows (DOM order, as set by SortableJS). Empty options (without a name) are dropped later by the Api, not here.

Parameters
$values : ArrayHash<string|int, mixed>
Return values
array<int, array{optionId: int, active: bool, default: bool, searchDefault: bool, texts: array}>

editedParameterOptions()

Returns the options (child parameters) of the edited parameter, with translations, ordered by `lft`.

private editedParameterOptions() : array<int, BaseEntity|ParameterInterface>

They are loaded separately instead of through the entity optionsCollection: because of the self-referencing hydrator that collection must not be serialized on the save path (see ParameterPresenter::actionEdit()).

Return values
array<int, BaseEntity|ParameterInterface>

optionRowField()

private optionRowField(mixed $row, string $key) : mixed
Parameters
$row : mixed
$key : string

optionRowInt()

private optionRowInt(mixed $row, string $key) : int
Parameters
$row : mixed
$key : string
Return values
int
On this page

Search results