trait HasLabelsTrait

Methods

static array
getConfigFields()

Provides a default has_labels config option.

static array
getEditFDL(Controller $mod, array $field, Form $form, int $profileId, int $copyId, array $config)

Generates key => value pairs to map database-saved keys to displayed labels for form fields (e.g. in select dropdowns), if field has labels.

static string
getValueLabels(string|null $propertyConfig, string $propertyValues, string $propertyValue, string $glue = '; ')

Replaces all keys with the according labels in the property's value.

static bool
hasLabels(string|null $propertyConfig)

Returns whether the field is configured to use labels.

static array
parseLabeledValues(string|null $propertyConfig, string $propertyValues)

Parses the property's values string into an array with key => value pairs, for example: "key1=label1;key2=label2" becomes ['key1' => 'label1', 'key2' => 'label2'].

Details

at line 17
static array getConfigFields()

Provides a default has_labels config option.

Return Value

array

at line 38
static array getEditFDL(Controller $mod, array $field, Form $form, int $profileId, int $copyId, array $config)

Generates key => value pairs to map database-saved keys to displayed labels for form fields (e.g. in select dropdowns), if field has labels.

Parameters

Controller $mod
array $field
Form $form
int $profileId
int $copyId
array $config

Return Value

array

at line 116
static string getValueLabels(string|null $propertyConfig, string $propertyValues, string $propertyValue, string $glue = '; ')

Replaces all keys with the according labels in the property's value.

The key=value pairs are generated from all possible values of the property. Handles also multiple values, e.g. for Checkbox.

Parameters

string|null $propertyConfig

The property's config

string $propertyValues

All valid values of the property, possibly as key=value pairs

string $propertyValue

The property's actual value, in which to replace the keys with the labels

string $glue

Used to concat the parsed labels

Return Value

string

The replaced and concatenated labels for the property value

at line 70
static bool hasLabels(string|null $propertyConfig)

Returns whether the field is configured to use labels.

The $propertyConfig string is parsed into an array and checked for the has_labels key.

Parameters

string|null $propertyConfig

The property's config string.

Return Value

bool

true if field has labels.

at line 85
static array parseLabeledValues(string|null $propertyConfig, string $propertyValues)

Parses the property's values string into an array with key => value pairs, for example: "key1=label1;key2=label2" becomes ['key1' => 'label1', 'key2' => 'label2'].

Parameters

string|null $propertyConfig

The property's config

string $propertyValues

Return Value

array