Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While working on issue #1482958: Allow field_group with empty fields to be displayed via setting (comment #27) I found out this function description and name confusing/conflicting:
/**
* Determine if an element has non-empty children.
*/
function _field_group_is_empty_element($element, $entity, $childname, $groups) {}
So does it determine non-empty children or empty element? Or is it just me not understanding?
Comments
Comment #2
morbiD CreditAttribution: morbiD commentedTotally agree that this function is confusing.
I believe the description is "correct" since the function returns TRUE when the element has non-empty children. However, that means the function is returning the opposite of what the name implies.
I mean, if I'm calling a function named
is_empty_element()
on an element with child content, I expect it to return FALSE; not TRUE.Given what the function actually does, it should be named
element_has_children()
or something like that.