Over in #1742438: Vertical tabs header and container rendered even when no vertical tabs we added logic to ensure the user can see at least one tab before rendering the vertical tab wrapper, hidden field and h2 title.
In comment 16, @webchick noted that it would be useful this logic in a helper function.

This task is a follow-up to ensure that idea doesn't get lost.

The code was like so:

+++ b/core/includes/form.inc
@@ -3796,11 +3796,26 @@ function form_process_vertical_tabs($element, &$form_state) {
+  foreach (element_children($element['group']) as $tab_index) {
+    if (!isset($element['group'][$tab_index]['#access']) ||
+        !empty($element['group'][$tab_index]['#access'])) {
+      $visible_tab = TRUE;
+      break;
+    }
+  }

Comments

mgifford’s picture

Thanks! Any ideas on what this function should be named?

larowlan’s picture

hmm
vertical_tabs_tab_access ?
best I've got for this early in the morning!

fenda’s picture

Assigned: Unassigned » fenda

I'll give this a go with the proposed function name vertical_tabs_tab_access.

fenda’s picture

Status: Active » Needs review
StatusFileSize
new1.85 KB

Here's a quick patch. Some questions:

  • Is it OK to have the new helper function in form.inc?
  • Are my comments OK?

Status: Needs review » Needs work

The last submitted patch, vertical-tab-access-helper-1800434-4.patch, failed testing.

fenda’s picture

Status: Needs work » Needs review
StatusFileSize
new1.85 KB

Oops, left out an important line.

The last submitted patch, vertical-tabs-access-helper-1800434-6.patch, failed testing.

fenda’s picture

Status: Needs work » Needs review
mgifford’s picture

Status: Needs review » Needs work

The last submitted patch, 6: vertical-tabs-access-helper-1800434-6.patch, failed testing.

biro.botond’s picture

Assigned: fenda » biro.botond
Issue summary: View changes
pasive’s picture

Version: 8.x-dev » 7.x-dev

Well guys I don't think this issue still applies to Drupal 8 as there is no more "theme_vertical_tabs" function in the core.

The issue though might still be applicable to Drupal 7 so I am changing it to relevant version.

I'd like others input testing this is the issue still applies and can be reproduced!

pasive’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: vertical-tabs-access-helper-1800434-6.patch, failed testing.

pasive’s picture

Uploading new patch to match current code base.

pasive’s picture

Correct name-spacing for the patch

gaurav.goyal’s picture

Status: Needs work » Needs review

Changing Status of this issue to need review, so that this patch can be reviewed.

mgifford’s picture

Assigned: biro.botond » Unassigned

Great to see that @pasive patch still applies.

It's already in D8, what manual testing is required? Seems to work fine.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.