function OptionsAllowedValuesInterface::getAllowedValues

Same name and namespace in other branches
  1. main core/modules/options/src/OptionsAllowedValuesInterface.php \Drupal\options\OptionsAllowedValuesInterface::getAllowedValues()

Returns the array of allowed values for a list field.

The strings are not safe for output. Keys and values of the array should be sanitized through \Drupal\Core\Field\AllowedTagsXssTrait::fieldFilterXss() before being displayed.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $definition: The field storage definition.

\Drupal\Core\Entity\FieldableEntityInterface|null $entity: (optional) The specific entity when this function is called from the context of a specific field on a specific entity. This allows custom 'allowed_values_function' callbacks to either restrict the values or customize the labels for particular bundles and entities. NULL when there is not a specific entity available, such as for Views filters.

Return value

array The array of allowed values. Keys of the array are the raw stored values (number or text), values of the array are the display labels.

See also

callback_allowed_values_function()

File

core/modules/options/src/OptionsAllowedValuesInterface.php, line 37

Class

OptionsAllowedValuesInterface
Provides an interface to get allowed values for a list field.

Namespace

Drupal\options

Code

public function getAllowedValues(FieldStorageDefinitionInterface $definition, ?FieldableEntityInterface $entity = NULL) : array;

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.