Loading core/modules/views/src/EntityViewsData.php +5 −1 Original line number Diff line number Diff line Loading @@ -596,8 +596,12 @@ protected function mapSingleFieldViewsData($table, $field_name, $field_type, $co } } // Do post-processing for a few field types. if (!$field_definition->isRequired()) { // Provides "Is empty (NULL)" and "Is not empty (NOT NULL)" operators. $views_field['filter']['allow empty'] = TRUE; } // Do post-processing for a few field types. $process_method = 'processViewsDataFor' . Container::camelize($field_type); if (method_exists($this, $process_method)) { $this->{$process_method}($table, $field_definition, $views_field, $column_name); Loading core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php +8 −0 Original line number Diff line number Diff line Loading @@ -428,6 +428,14 @@ public function testBaseTableFields(): void { ], ], ], $data['entity_test__string']['table']['join']['entity_test']); // Check the "allow empty" option for non-required fields. $this->assertArrayHasKey('allow empty', $data['entity_test']['name']['filter']); $this->assertTrue($data['entity_test']['name']['filter']['allow empty']); // Reconfigure the field to be required. $this->commonBaseFields['name']->setRequired(TRUE); $data = $this->entityTypeManager->getHandler('entity_test', 'views_data')->getViewsData(); $this->assertArrayNotHasKey('allow empty', $data['entity_test']['name']['filter']); } /** Loading Loading
core/modules/views/src/EntityViewsData.php +5 −1 Original line number Diff line number Diff line Loading @@ -596,8 +596,12 @@ protected function mapSingleFieldViewsData($table, $field_name, $field_type, $co } } // Do post-processing for a few field types. if (!$field_definition->isRequired()) { // Provides "Is empty (NULL)" and "Is not empty (NOT NULL)" operators. $views_field['filter']['allow empty'] = TRUE; } // Do post-processing for a few field types. $process_method = 'processViewsDataFor' . Container::camelize($field_type); if (method_exists($this, $process_method)) { $this->{$process_method}($table, $field_definition, $views_field, $column_name); Loading
core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php +8 −0 Original line number Diff line number Diff line Loading @@ -428,6 +428,14 @@ public function testBaseTableFields(): void { ], ], ], $data['entity_test__string']['table']['join']['entity_test']); // Check the "allow empty" option for non-required fields. $this->assertArrayHasKey('allow empty', $data['entity_test']['name']['filter']); $this->assertTrue($data['entity_test']['name']['filter']['allow empty']); // Reconfigure the field to be required. $this->commonBaseFields['name']->setRequired(TRUE); $data = $this->entityTypeManager->getHandler('entity_test', 'views_data')->getViewsData(); $this->assertArrayNotHasKey('allow empty', $data['entity_test']['name']['filter']); } /** Loading