function options_allowed_values
Same name and namespace in other branches
- 10 core/modules/options/options.module \options_allowed_values()
- 9 core/modules/options/options.module \options_allowed_values()
- 8.9.x core/modules/options/options.module \options_allowed_values()
- main core/modules/options/options.module \options_allowed_values()
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\FieldFilteredMarkup 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.
Deprecated
in drupal:11.5.0 and is removed from drupal:13.0.0. Use \Drupal\options\OptionsAllowedValuesInterface::allowedValues() instead.
See also
https://www.drupal.org/node/3572185
1 string reference to 'options_allowed_values'
- drupal_static_reset in core/
includes/ bootstrap.inc - Resets one or all centrally stored static variable(s).
File
-
core/
modules/ options/ options.module, line 36
Code
function options_allowed_values(FieldStorageDefinitionInterface $definition, ?FieldableEntityInterface $entity = NULL) {
@trigger_error(__METHOD__ . '() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Use \\Drupal\\options\\OptionsAllowedValuesInterface::allowedValues() instead. See https://www.drupal.org/node/3572185', E_USER_DEPRECATED);
return \Drupal::service(OptionsAllowedValuesInterface::class)->getAllowedValues($definition, $entity);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.