diff --git a/core/modules/options/lib/Drupal/options/Plugin/field/widget/OptionsWidgetBase.php b/core/modules/options/lib/Drupal/options/Plugin/field/widget/OptionsWidgetBase.php index 2301789..f73bd1b 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/field/widget/OptionsWidgetBase.php +++ b/core/modules/options/lib/Drupal/options/Plugin/field/widget/OptionsWidgetBase.php @@ -18,9 +18,9 @@ * Field types willing to enable one or several of the widgets defined in * options.module (select, radios/checkboxes, on/off checkbox) need to * implement the AllowedValuesInterface to specify the list of options to - * display in the widgets. + * display in the widgets, or implement getSettableOptions(). * - * @see \Drupal\Core\TypedData\AllowedValuesInterface + * @see \Drupal\Core\TypedData\AllowedValuesInterface::getSettableOptions() */ abstract class OptionsWidgetBase extends WidgetBase { diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/field_type/TaxonomyTermReferenceItem.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/field_type/TaxonomyTermReferenceItem.php index 9e5bc00..177033e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/field_type/TaxonomyTermReferenceItem.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/field_type/TaxonomyTermReferenceItem.php @@ -10,6 +10,7 @@ use Drupal\field\FieldInterface; use Drupal\field\Plugin\Type\FieldType\ConfigEntityReferenceItemBase; use Drupal\field\Plugin\Type\FieldType\ConfigFieldItemInterface; +use Drupal\Core\Session\AccountInterface; /** * Plugin implementation of the 'term_reference' field type. @@ -140,6 +141,16 @@ public function getConstraints() { } /** + * {@inheritdoc} + */ + public function getSettableOptions(AccountInterface $account = NULL) { + $instance = $this->getFieldDefinition(); + $entity = $this->getParent()->getParent(); + $function = $this->getFieldSetting('options_list_callback') ? $this->getFieldSetting('options_list_callback') : 'taxonomy_allowed_values'; + return $function($instance, $entity); + } + + /** * Flattens an array of allowed values. * * @param array $array