diff --git a/core/modules/field/modules/entityreference/entityreference.module b/core/modules/field/modules/entityreference/entityreference.module index 4d17efa..d0ad084 100644 --- a/core/modules/field/modules/entityreference/entityreference.module +++ b/core/modules/field/modules/entityreference/entityreference.module @@ -288,12 +288,9 @@ function entityreference_field_widget_info_alter(array &$info) { */ function entityreference_options_list($field, $instance = NULL, $entity_type = NULL, $entity = NULL) { $options = entityreference_get_selection_handler($field, $instance, $entity_type, $entity)->getReferencableEntities(); - if (count($options) == 1) { - // Change the optgroup to a flat array. - $key = key($options); - $options = $options[$key]; - } - return $options; + // Change the optgroup to a flat array if the results are from a single + // bundle. + return (count($options) == 1) ? reset($options) : $options; } /**