Accordion default unclear

Created on 31 July 2023, over 1 year ago
Updated 22 November 2023, 12 months ago

Problem/Motivation

I think the accordion code in the .module file has a line from the tabs section so the settings are not working. I found it sometimes showing as open, but with no content under it till I clicked on it.

Steps to reproduce

If you look at the options in the Bootstrap Accordion, it seems to be asking for a default tab, rather than a default state of open or closed.

Proposed resolution

For my case (which is I want them all open), I changed the Accordion section to what is shown below. However, I realize this isn't really a fix since not everyone wants them all open all the time:

      case 'bootstrap_accordion':
        foreach ($group->children as $child) {
          if (!empty($element[$child])) {
            $element[$child]["#button_attributes"] = new Attribute($field_group_element["#items"][$child]["#attributes"]);
            $element[$child]["#title"] = $field_group_element["#items"][$child]["#title"];
            $element[$child]["#parent_id"] = $field_group_element["#id"];
            $element[$child]["#theme_wrappers"] = ['field_group_bootstrap_accordion'];
            if (!empty($element[$child]['widget'])) {
              hide_form_title($element[$child]['widget']);
            }
            $element[$child]["#collapse"] = 'show';
          }
        }
        $element['#attached']['library'][] = 'field_group_bootstrap/field_group_boostrap';
        break;

Removing this:

            if (!empty($field_group_element["#default_tab"]) && $field_group_element["#default_tab"] == $child) {
              $element[$child]["#attributes"]["class"][] = 'show active';
            }

In addition, it won't let me add a new Bootstrap Accordion field group, so I have to add it as another type, then change it to Bootstrap Accordion. The error is this (this happened before I made my change):

Warning: Undefined property: stdClass::$children in Drupal\field_group_bootstrap\Plugin\field_group\FieldGroupFormatter\BootstrapAccordion->settingsForm() (line 143 of modules/contrib/field_group_bootstrap/src/Plugin/field_group/FieldGroupFormatter/BootstrapAccordion.php).

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States duckydan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024