diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php index 2534474..b590de9 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php @@ -120,7 +120,8 @@ protected function getOptions(FieldableEntityInterface $entity) { ->getSettableOptions(\Drupal::currentUser()); // Add an empty option if the widget needs one. - if ($empty_option = $this->getEmptyOption()) { + $empty_option = $this->getEmptyOption(); + if (!empty($empty_option)) { $options = $empty_option + $options; } @@ -196,8 +197,9 @@ protected function sanitizeLabel(&$label) { /** * Returns the empty option and label to add to the list of options, if any. * - * @return array|null - * Either _none as a key and value as a label of the empty option, or NULL. + * @return array + * Either '_none' as a key and value as a label of the empty option, or an + * empty array if widget does not support empty option. */ protected function getEmptyOption() { }