- Issue created by @prudloff
arora.shivani → made their first commit to this issue’s fork.
ExtraFieldDisplayFormattedBase::view()
checks if a field is empty with !empty($elements)
.
I think it would make more sense to use Element::isEmpty()
here, as it would consider a field with only #cache
empty.
I know we can manually specify if a field is empty with something like this:
$this->isEmpty = Element::isEmpty($build));
But it would be useful if we did not have to specify it for basic use cases. (Specifying isEmpty
manually would still be useful for more complex cases.)
Very basic example of a field that is empty but does not return an empty array:
public function viewElements(ContentEntityInterface $entity): array {
return [
'#cache' => ['max-age' => 42],
];
}
We could do something like this:
if (!Element::isEmpty($elements) && !$this->isEmpty()) {
But would this break retro-compatibility? I guess it could consider fields empty that were not considered empty before.
Active
2.0
Code
arora.shivani → made their first commit to this issue’s fork.