Vertical Tabs breaks Content Multigroup when "Add more values" button is processed
crea - October 3, 2009 - 14:40
| Project: | Vertical Tabs |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
When I set multigroup to be displayed as Vertical Tab, it is displayed fine until I press "Add more values" button. When pressed, the button JS creates copy of multigroup outside of VT, and adds item to it, instead of adding new row to the multigroup in VT.
I don't put it in VT queue cause it works fine with CCK 2.x. Feel free to move it to VT queue if you think VT must change it's behaviour in some way.

#1
Setting proper title.
Also, it's worth to note, that when multigroup is rendered as fieldset inside vertical tab, "add more values" works fine. Because of this, and the fact other CCK "add more" buttons work fine inside Vertical Tab, I tend to think this is problem in content_multigroup JS which fails to find proper place to add item.
#2
#3
I have installed Vertical Tabs to try to debug this, and I've found the problem, but I'm afraid this cannot be fixed in Content Multigroups module. Let's see...
Vertical Tabs searches for top level elements in the form that are fieldsets, and if enabled in Content Type settings form, it manages them in the node edit form. Here, Vertical Tabs moves the whole fieldset to a new position in the DOM.
The problem is that the fieldset used by multigroups is wrapped with a div that is necessary for the AHAH processing of the "Add more values" button. While Vertical Tabs moves the fieldset in the DOM, the AHAH wrapper of the multigroup remains in its original position, and this is what is replaced by the AHAH callback, so after the "Add more values" button has been processed, the form ends up with 2 multigroups (the one that was moved by Vertical Tabs to its new position and the one that comes from the AHAH response).
The multigroup module cannot move this wrapper inside the fieldset because both things are part of the same form element. Well, I cannot see a reliable way to do it from content_multigroup_add_more_js().
On the other hand, maybe the Vertical Tabs module could take this into account and process the fieldset wrapper (not the fieldset itself, but its wrapper) when it is related to AHAH stuff?
#4
Moving to the VT queue, as I think this cannot be done in multigroups module. On the other hand, VT would have to move the DOM element used to wrap the fieldset instead of the fieldset itself.
#5
Another thing VT could do is inject its own wrapper to the fieldset during hook_form_alter(), using #prefix and #suffix, and then it could manipulate this DOM element instead of altering the elements owned by other modules, because it is now breaking Content Multigroup, but it could probably break others.
#6
#7
For anyone interested, as temporary workaround I did the following.
Created separate module that implements hook_form_alter() and #pre-render callback. In hook_form_alter() I created new top level fieldset form element, and attached copy of multigroup as child element. Then in pre-render callback I unset original multigroup form element (if I unset it in hook_form_alter(), multigroup AHAH callback can't find it and complains).
Importand part is to give this module weight more than multigroup but less than vertical_tabs, so when it's code runs, multigroup is already available in the form and new fieldset that we add becomes available to vertical_tabs later.
#8
Subscribing
I would really like this functionality with VT and multigroups for my custom node forms. netaustin placed a patch for tabs.module for fieldgroup_tabs to work with multigroups, maybe some of the code can be used as seed for this issue. See here http://drupal.org/node/590386.
Would appreciate it crea if you could share patch or module solution you described above.
#9
Patch is not possible since it's custom solution related to my site. It would be possible to make this as independent module, but I won't waste time doing it cause it can (and should) be fixed in VT module at any moment. Instructions I posted are enough to make your custom workaround. If you can't program, sorry, you have to wait for bugfix.
#10
Confirming this problem in the latest vertical tabs release and that this still needs to be fixed. Can vertical tabs include official compatibility for multigroups? Thank you!
#12
I don't use CCK Multigroup so it will require someone to submit a patch and others to review it.
#13
Please test and re-confirm using the latest code, 6.x-1.0-beta6.
#14
I just upgraded to the latest release, updated the database and I get the following error
Fatal error: Call to undefined function vertical_tabs_fieldsets() in /home/gov/mysite/WWW/mysite.com/sites/all/modules/vt_default/vt_default.module on line 58#15
That's a problem with the vt_default.module. Please open a new issue at http://drupal.org/project/issues/vt_default
#16
I tried beta6 and bug is still there...copy of multigroup is created outside of VT when "add more" is pressed.
#17
Confirming that duplicate display bug is still there (and my vt-default problem is now fixed in that project-- sorry about the stray issue)
#18
#19
Here is a screen-shot of the cck fieldset (a multigroup) on the edit form. When selecting "Add more values" the fieldset is still rendered a second time on the page and outside the vertical tabs display. What other information can I supply you in order to help?