1

I have a custom module (written for Drupal 6) which defines a new content type. In Drupal 6 I have used several fieldsets and Vertical Tabs module to have the custom node form more clearly laid out. It looked like this

$form['event'] = array(
    '#type' => 'fieldset',
    '#title' =>  t('Event'),
    '#weight' => -2,
);

While porting that module to Drupal 7, I altered that section to use the now-in-core functionality to

M$form['event'] = array(
    '#type' => 'fieldset',
    '#title' =>  t('Event'),
    '#weight' => -2,
    '#group' => 'vt_event',
    '#collapsed' => true,
    '#collapsible' => true,
);
$form['vt_event'] = array(
    '#type' => 'vertical_tabs',
);

This indeed works just fine, when converting up to three fieldsets to the new structure. However, my form is more complex and I need at least five additional fieldsets. But as soon as I convert the fourth fieldset to enable it for vertical tabs, I suddenly get 500 server errors.

Does anyone have any idea why this is happening? It's always the fourth fieldset when it breaks the site and it's regardless which fieldset is the fourth (I tried to enable three other fieldsets first, but again it breaks on the fourth one which worked before).

1 Answer 1

0

While driving me nuts yesterday, I started over again today and cleaned up the module a bit. During that I tried to add another vertical tab again (#4) and this time it worked. By accident, I did re-use a group name and by this I finally was getting fully aware of how this is intended to work.

My mistake was to create a form element of type "vertical_tabs" for each first-level fieldset. But it is sufficient to only have on "vertical_tabs" form element and assign all fieldsets to that group (they actually are grouped then).

So, everything is fine with my code above but the last three lines are only required once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.