Vertical tabs weights incorrect (cck interaction issue)

garywiz - October 25, 2009 - 00:14
Project:Vertical Tabs
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

Vertical tabs do not appear in the order set in the CCK "Manage Fields" reordering interface. Often things in tabs are completely rearranged and almost seems random. I have confirmed this under a variety of scenarios and I can see what is causing it. But, I am not sure what to do about it, though I have "patched" my module to work a bit better, but not perfectly.

Hopefully somebody who has a better understanding of "weights" can help.

The problem is here at about line 45 (in 1.x-dev):

       // Add the JavaScript.
       $settings[$key] = array(
         'name' => $form[$key]['#title'],
         'weight' => (isset($form[$key]['#weight']) ? $form[$key]['#weight'] : 0) + (0.01 * $delta),
         'callback' => (isset($form[$key]['#summary_callback']) ? $form[$key]['#summary_callback'] : $key),
         'args' => (isset($form[$key]['#summary_arguments']) ? $form[$key]['#summary_arguments'] : array()),
       );

This should work, as it uses the weights directly from the $form definition and it took me a while to figure out why it wasn't working.

The reason is because content.module has a #pre_render function called 'content_alter_extra_weights'. After all form alterations are made, it changes the weights based upon a variety of criteria that I don't really understand.

Almost taking stabs in the dark, I changed the weight line in the above code to this (based upon my reading of what content.module does)...

       // Add the JavaScript.
       $settings[$key] = array(
         'name' => $form[$key]['#title'],
        'weight' => (isset($form['#content_extra_fields'][$key]['weight'])? $form['#content_extra_fields'][$key]['weight'] : $form[$key]['#weight']),
         'callback' => (isset($form[$key]['#summary_callback']) ? $form[$key]['#summary_callback'] : $key),
         'args' => (isset($form[$key]['#summary_arguments']) ? $form[$key]['#summary_arguments'] : array()),
       );

Unbelievably, the ordering of the fields in vertical tabs is now much better! At least the critical fields we dragged to the top are now at the top instead of at the bottom, and irrelevant stuff (for us, Revisions for example), are at the bottom and out of the way.

It still isn't right, I'm sure, because I don't understand exactly why weights are being manipulated in such convoluted ways.

But, hopefully, the above will shed some light on why this is happening for those who have more experience.

#1

BenK - October 25, 2009 - 20:43

Subscribing.... I'm also experiencing this issue and would love a solution!

--Ben

#2

dww - November 1, 2009 - 20:05
 
 

Drupal is a registered trademark of Dries Buytaert.