CRUDUI PHP API

ChoiceList
in package

FinalYes

Read choice lists: `items` arrays of value and label pairs kept in list order.

Table of Contents

Constants

EXPECTED  : mixed = 'value and label pairs with distinct string or...
The expected-value text of a choice list declaration failure.
APPEARANCE_MEMBERS  : mixed = ['class', 'style', 'attributes']
The members a choice of a choice or multichoice field may declare besides value and label.

Methods

appearances()  : array<int, array<string, mixed>>
The appearance of each choice of a checked choice list in list order: className, style (normalized as a design style) and attributes, each only when declared.
checkAppearance()  : void
Reject the appearance of a valid choice list whose class or style is not a string or whose attributes break the declared attribute rules, choice by choice in list order.
groups()  : array<int, array{index: int, label: mixed}|null>
The group of each pair of a checked choice list in the order of pairs(): the index of the group in the list and its declared label, or null for a choice outside groups.
is()  : bool
Whether `items` is a choice list: an array with an object element that has a `value` or a `choices` member.
pairs()  : array<int, array{0: string, 1: mixed}>|null
The value text and label pairs in list order, the choices of each group in place of the group, or null when an element has another member (an appearance member is accepted with $appearance), lacks value or label, has a value that is not a string or a finite number, or repeats the canonical text of an earlier value, or when the list has a group without $groups or a group that is not a label and a non-empty list of choices without appearance members.
resolve()  : stdClass
The spec of a field whose `items` is a group source, with `items` replaced by the choices that the source gives for the root form data as a choice list of value and label pairs; any other spec is returned as it is.
isGroup()  : bool
Whether a choice list element is a group: an object that has a `choices` member.

Constants

EXPECTED

The expected-value text of a choice list declaration failure.

public mixed EXPECTED = 'value and label pairs with distinct string or number values'

APPEARANCE_MEMBERS

The members a choice of a choice or multichoice field may declare besides value and label.

private mixed APPEARANCE_MEMBERS = ['class', 'style', 'attributes']

Methods

appearances()

The appearance of each choice of a checked choice list in list order: className, style (normalized as a design style) and attributes, each only when declared.

public static appearances(array<int, stdClass> $items) : array<int, array<string, mixed>>
Parameters
$items : array<int, stdClass>
Return values
array<int, array<string, mixed>>

checkAppearance()

Reject the appearance of a valid choice list whose class or style is not a string or whose attributes break the declared attribute rules, choice by choice in list order.

public static checkAppearance(array<int, stdClass> $items, string $path) : void
Parameters
$items : array<int, stdClass>
$path : string

groups()

The group of each pair of a checked choice list in the order of pairs(): the index of the group in the list and its declared label, or null for a choice outside groups.

public static groups(array<int, mixed> $items) : array<int, array{index: int, label: mixed}|null>
Parameters
$items : array<int, mixed>
Return values
array<int, array{index: int, label: mixed}|null>

is()

Whether `items` is a choice list: an array with an object element that has a `value` or a `choices` member.

public static is(mixed $items) : bool
Parameters
$items : mixed
Return values
bool

pairs()

The value text and label pairs in list order, the choices of each group in place of the group, or null when an element has another member (an appearance member is accepted with $appearance), lacks value or label, has a value that is not a string or a finite number, or repeats the canonical text of an earlier value, or when the list has a group without $groups or a group that is not a label and a non-empty list of choices without appearance members.

public static pairs(array<int, mixed> $items[, bool $appearance = false ][, bool $groups = false ]) : array<int, array{0: string, 1: mixed}>|null
Parameters
$items : array<int, mixed>
$appearance : bool = false
$groups : bool = false
Return values
array<int, array{0: string, 1: mixed}>|null

resolve()

The spec of a field whose `items` is a group source, with `items` replaced by the choices that the source gives for the root form data as a choice list of value and label pairs; any other spec is returned as it is.

public static resolve(stdClass $spec, stdClass $data) : stdClass
Parameters
$spec : stdClass
$data : stdClass
Return values
stdClass

isGroup()

Whether a choice list element is a group: an object that has a `choices` member.

private static isGroup(mixed $item) : bool
Parameters
$item : mixed
Return values
bool
On this page

Search results