I am using the Field Group module to create a set of vertical tabs for organizing fields on my entity types. If I create another "fieldset" Field Group inside a vertical tab, and make it "collapsible" or "collapsed" it does not work as expected. Clicking on the panel title does not open/close the fieldset.

I traced this to the following lines in bootstrap-panel.vars.php:

  // Force grouped fieldsets to not be collapsible (for vertical tabs).
  if (!empty($element['#group'])) {
    $variables['collapsible'] = FALSE;
    $variables['collapsed'] = FALSE;
  }

If I remove that block, then it fixes the issue.

Here is the commit that added that code: http://cgit.drupalcode.org/bootstrap/commit/?id=3425ff6

And the issue that it originated in: #2112849: Nested fieldset/vertical tabs don't always show contents

It sounds like it was a broad fix for a more complicated issue.

I think part of that issue may have been solved since then, in this issue: #2468625: bootstrap_preprocess_bootstrap_panel() overwrites element id

I am not 100% sure, though - as I'm not very familiar with the discussion in #2112849: Nested fieldset/vertical tabs don't always show contents (and it's been a while since I wrote the patch in #2468625: bootstrap_preprocess_bootstrap_panel() overwrites element id).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

m.stenta created an issue. See original summary.

m.stenta’s picture

Status: Active » Needs review
FileSize
804 bytes

Attached is a patch that removes the "Force grouped fieldsets to not be collapsible (for vertical tabs)." block. I think we should test that with the original issue in #2112849: Nested fieldset/vertical tabs don't always show contents and see if it is still necessary. If not, I think we can remove it!

m.stenta’s picture

m.stenta’s picture

My patch in #2 will not apply if you have already applied the #10 patch from #2634358: Multiple collapsible fieldsets have broken triggers in BS3.3.4 (which I need to do in my Drush Make file).

So, attached is another patch that I made AFTER that patch was applied. I figure that issue might get committed first, since it has more followers/interest, so this one would probably come after it anyways (if at all). In either case, both versions of the patch are now available to choose from. :-)

  • markcarver committed 73fdc01 on 7.x-3.x authored by m.stenta
    Issue #2910624 by m.stenta: Collapsible fieldsets inside vertical tabs...
markhalliwell’s picture

Status: Needs review » Fixed

This doesn't appear to be affecting anything, so committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

markhalliwell’s picture

Status: Closed (fixed) » Needs work
Related issues: +#2938574: Advanced Search and Horizontal Tabs broken

This commit ended up affecting more than met the eye, see #2938574: Advanced Search and Horizontal Tabs broken.

I'm reverting this commit.

  • markcarver committed 4431f7e on 7.x-3.x
    Revert "Issue #2910624 by m.stenta: Collapsible fieldsets inside...
m.stenta’s picture

Dang. I'll try to take a closer look at that issue and see what's going on.

m.stenta’s picture

I asked for steps to reproduce: https://www.drupal.org/project/bootstrap/issues/2938574#comment-12466940

Will see if I can reproduce with some simple horizontal tabs.

m.stenta’s picture

I was able to replicate the issue described in #2938574: Advanced Search and Horizontal Tabs broken.

Here is the setup that I created - for testing both horizontal and vertical tabs, with collapsible fieldsets in each.

Start by creating a new entity bundle for testing. Then create the following field groups and fields in it (hopefully the line indents come across - couldn't get ULs to work for some reason):

- Horizontal tabs (group_horizontal)
---- Htab1 (group_htab1)
-------- Text1 (field_text1)
---- Htab2 (group_htab2)
-------- Collapsible1 (group_collapsible1)
------------ Text2 (field_text2)
---- Htab3 (group_htab3)
-------- Collapsed1 (group_collapsed1)
------------ Text3 (field_text3)
- Vertical tabs (group_vertical)
---- Vtab1 (group_vtab1)
-------- Text4 (field_text4)
---- Vtab2 (group_vtab2)
-------- Collapsible2 (group_collapsible2)
------------ Text5 (field_text5)
---- Vtab3 (group_vtab3)
-------- Collapsed2 (group_collapsed2)
------------ Text6 (field_text6)

Attached are two screenshots that show what it looks like in my site:

Then, adding/removing the following block of code from bootstrap-panel.vars.php allows me to toggle back and forth between the issue described in #2938574: Advanced Search and Horizontal Tabs broken and the one described in this issue (#2910624: Collapsible fieldsets are disabled when group is set).

  // Force grouped fieldsets to not be collapsible (for vertical tabs).
  if (!empty($element['#group'])) {
    $variables['collapsible'] = FALSE;
    $variables['collapsed'] = FALSE;
  }

WITH the code block: Horizontal and vertical tabs both show their content. But collapsible fieldsets do not work in any of them. The collapsed fieldset is open, and neither can be closed.

WITHOUT the code block: Horizontal tabs are completely empty. No content is shown at all. Vertical tabs, on the other hand, show their content fine - and the collapsed and collapsible fieldsets work as expected in the vertical tabs.

m.stenta’s picture

So... there must be something else going on with horizontal tabs specifically that is breaking when $variables['collapsible'] = TRUE; and/or $variables['collapsed'] = TRUE;.

My gut tells me THAT is the real issue, and ultimately we should fix that AND reinstate the change made previously (to remove the block of code again).

m.stenta’s picture

OK interestingly: if you comment out EITHER $variables['collapsible'] = FALSE; OR $variables['collapsed'] = FALSE;, it does not break the horizontal tab content. BOTH need to be commented out in order for it to break (also happens if BOTH are set to TRUE, but not if only one is).

m.stenta’s picture

Afraid I won't be able to go much deeper this week. Maybe someone else can pick this up and run with it. I'll try to jump back in when I have some time.

hass’s picture

Title: Collapsible fieldsets inside vertical tabs are disabled » Collapsible fieldsets are disabled
Related issues: +#2948135: Fieldsets are empty in forms (7.x-3.18 or later)

This issue is not limited to vertical tabs.

markhalliwell’s picture

Title: Collapsible fieldsets are disabled » Collapsible fieldsets are disabled when group is set

A more apt title

m.stenta’s picture

I took this debugging one step further in the bootstrap_preprocess_bootstrap_panel() function.

Commenting out the following lines further down in the function has the same affect as described in comments #12, #13, and #14 above.

  // Add more classes to the body if collapsible.
  if ($variables['collapsible']) {
    $body_classes[] = 'panel-collapse';
    //$body_classes[] = 'collapse';
    //$body_classes[] = 'fade';
    $body_classes[] = $variables['collapsed'] ? 'collapsed' : 'in';
  }
  _bootstrap_add_class($body_classes, $element, 'body_attributes');

It seems that the presence of the "collapse" and "fade" classes on the panel body specifically affect this. If those classes are added, vertical tabs work and child fieldsets are collapsed as expected, but horizontal tabs are empty. If they are not added, horizontal tabs work, but vertical tab child fieldsets are not collapsed. This is the same outcome as I described in comments #12, #13, and #14 above.

m.stenta’s picture

OK! Now I'm getting somewhere... Attached is a patch that fixes the issue - BUT IT IS NOT COMPLETE. It just serves to demonstrate the issue by fixing it in a very specific way. I don't think this is the right general fix.

It seems that the root issue is that the $element for horizontal tabs are starting with #collapsed set to TRUE, when they should be set to FALSE. This patch simply adds a condition to the top of the bootstrap_preprocess_bootstrap_panel() function to check if the element is a horizontal tab, and if so, it sets $variables['element']['#collapsed'] = FALSE;.

Combined with my original change, this fixes all the issues that have been reported thusfar, as far as I can tell:

  • - Collapsed fieldsets inside vertical tabs are collapsed as expected.
  • - Horizontal tabs are not empty.

So the next question is... why are horizontal tabs starting out with #collapsed set to TRUE?

m.stenta’s picture

Slight modification to my previous patch - this fixes a minor PHP notice I was seeing in some other pages.

Notice: Trying to get property of non-object in bootstrap_preprocess_bootstrap_panel() (line 21 of /var/www/html/profiles/farm/themes/bootstrap/templates/bootstrap/bootstrap-panel.vars.php).

It also points to the fact that $element['#group'] is sometimes an object, and sometimes not, which could be an issue in itself... ? I seem to recall discovering that more than one module was trying to use this variable, and were conflicting with each other... not directly related to this issue here, but something that might be good to know. I'll see if I can find that issue...

m.stenta’s picture

Oops dang, sorry - I made the same patch twice. Here is the fixed one.

markhalliwell’s picture

A module should not hijack an existing core render array property like this (which is expected to be a string, and its counterpart #groups as the array after #group as been processed).

It should be using a dedicated custom property that they access during their processing/rendering phase.

It should also be properly setting the #collapsible and #collapsed default states.

I'm tempted to say that this is ultimately a "major" issue with Field Group itself.

Perhaps, in this issue, we simply reapply #4 and then move/re-open #2938574: Advanced Search and Horizontal Tabs broken to Field Group for them to fix (referencing this issue's findings of course).

m.stenta’s picture

Yes that might be the right way to go about this. I agree the Field Groups module is at fault for overriding the #group property.

  • markcarver committed 5b223c8 on 7.x-3.x authored by m.stenta
    Issue #2910624 by m.stenta, markcarver: Collapsible fieldsets are...
markhalliwell’s picture

Status: Needs work » Fixed
markusa’s picture

Not sure how you call this fixed. Field Group module works with every other Drupal theme. Only Bootstrap you have problems. Now everyone plays the point the finger game, and in the meantime anyone using Bootstrap + Field Groups has broken horizontal tabs.

m.stenta’s picture

@markusa The patch that was committed has the following in it:

+  // Temporarily provide field_group "support" until properly "fixed" upstream.
+  // @see https://www.drupal.org/project/bootstrap/issues/2910624
+  if (!empty($variables['element']['#group']->format_type) && $variables['element']['#group']->format_type == 'htab') {
+    $variables['element']['#collapsed'] = FALSE;
+  }

So it should work. Can you please test the dev version of Bootstrap and confirm this? That would be helpful.

markusa’s picture

I tried the -dev version downloadable from the project page, and I see that the patch is there.

It did not solve the issue for me.

Perhaps original issue here is fixed, that is with the fieldsets in vertical tabs

I did create an issue to document the horizontal tabs issue, perhaps you'll want to continue discussion there to avoid muddying the waters, or just close it out if you want.

https://www.drupal.org/project/bootstrap/issues/2962225

m.stenta’s picture

@markusa Hmm I wonder if your issue is different... See my comment #12 above that describes how I replicated the horizontal tabs issue. If you read through my comments you'll see the trail I followed debugging both vertical tabs and horizontal tabs. Based on my tests, the patch fixed it. If you have a slightly different issue, it would help to have you go through the same process and see what exactly is different so that can be fixed as well. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

willzyx’s picture

I'm using bootstrap 3.20 and this realease, which coontains the patch, did not solve the issue for me. Looks like this commit cause a regression..

m.stenta’s picture

@willzyx - For horizontal tabs or for vertical tabs? Can you please provide more details or help to debug this? See my comment #12 above where I documented how I reproduced the issue. Please go through those steps and identify where our installations/configurations differ so that we can figure out what is causing the issue in your case. I describe in detail in my comments above what I discovered during the process. But maybe that is not the same setup you have. More info is needed - and probably a new bug report.

Todd Zebert’s picture

Perhaps related but recently I updated a site from 3.10 to 3.20 and we noticed some content wasn't showing. Prior, having a horizontal tab group, with all the horizontal tab items set to "closed" it would work. But once updating to 3.20 I had to change them all to "open" to get the same behavior.

markhalliwell’s picture

Not related. Separate issue that was documented in a change record.

CProfessionals’s picture

Same issue as #33 and Todd's work around worked great!

grahamvalue’s picture

Same issue as #33 and Todd's work around worked great!

Seconded.

Alan D.’s picture

Seems to have caused a lot of random issues with nested panels using Field Group even after updating the sub-theme overrides and setting these to Open as suggested by Todd. This could be possibly due to custom styling, possibly bug with nested field groups / fieldsets, but no time to investigate today.

If I find any issues, I report back. However reverting back pre-Bootstrap 7.x-3.18 was the quick fix (specifically to 7.x-3.15).