diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php index 62c32aa..b99daa6 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php @@ -16,6 +16,13 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInterface { /** + * The value. + * + * @var \Drupal\options\Plugin\Field\FieldType\ListItemBase + */ + protected $value; + + /** * {@inheritdoc} */ public static function defaultStorageSettings() { @@ -73,7 +80,18 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin * {@inheritdoc} */ public function isEmpty() { - return empty($this->value) && (string) $this->value !== '0'; + // Based on the PHP empty() function the value is not empty, so there's no need to continue. + if(!empty($this->value)) { + return FALSE; + } + // Type of list_boolean + elseif (isset($this->type) && $this->type == 'list_boolean') { + return (string) $this->value === '0'; + } + // Other types. + else { + return (string) $this->value !== '0'; + } } /**