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.
Most form elements have a #type set. In fact, all valid form elements except one kind have that.
This is in drupal_render():
// If #markup is set, ensure #type is set. This allows to specify just #markup
// on an element without setting #type.
if (isset($elements['#markup']) && !isset($elements['#type'])) {
$elements['#type'] = 'markup';
}
However, field_group_remove_empty_form_groups() ignores this distinction, and removes anything without a #type.
Additionally, it loops unnecessarily. Once it finds one child, it can stop looping.
Comment | File | Size | Author |
---|---|---|---|
#3 | fg-2212431-3.patch | 2.51 KB | tim.plunkett |
#1 | field_group-2212431-1.patch | 726 bytes | tim.plunkett |
Comments
Comment #1
tim.plunkettHere's the fix.
Comment #2
nils.destoop CreditAttribution: nils.destoop commentedThe check for markup has been added, but the break not.
The loop should always continue, if you break in the loop, it's possible that one of the level 2 children didn't got an #access FALSE. (it goes recursive into all the children, and children childrens)
Comment #3
tim.plunkettGood point.
However, you committed a little bit more than necessary.
Here's a patch to reduce the last commit to only fix the bug.
For posterity: http://drupalcode.org/project/field_group.git/commit/c6176eb
Comment #4
nils.destoop CreditAttribution: nils.destoop commentedYeah, i already noticed it :D The debug code was already removed.
Comment #5
nils.destoop CreditAttribution: nils.destoop commentedComment #10
nils.destoop CreditAttribution: nils.destoop commented