diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index 55c239d..56623b9 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -309,3 +309,30 @@ function hook_field_purge_field(\Drupal\field\Entity\FieldConfig $field) { /** * @} End of "addtogroup hooks". */ + +/** + * Specifies the allowed values list for a field. + * + * Callback for options_allowed_values(). + * + * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition + * The field definition. + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity object. + * @param bool $cacheable + * Specifies whether or not the allowed values will be statically cached. + * Defaults to FALSE, set to TRUE to cache the values. + * + * @return array + * An associative array with keys and values to use as the key|label setting(s) + * on a field's allowed value list. + * + * @ingroup callbacks + */ +function callback_allowed_values(FieldDefinitionInterface $field_definition, EntityInterface $entity, &$cacheable = FALSE) { + $values = array( + 0 => 'no', + 1 => 'yes' + ); + return $values; +} diff --git a/core/modules/options/options.module b/core/modules/options/options.module index d221adb..f8db3cb 100644 --- a/core/modules/options/options.module +++ b/core/modules/options/options.module @@ -69,6 +69,11 @@ function options_field_storage_config_delete(FieldStorageConfigInterface $field_ * * @see callback_allowed_values_function() */ + +/** + * Implements callback_allowed_values(). + * + */ function options_allowed_values(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL) { $allowed_values = &drupal_static(__FUNCTION__, array());