Support for location module
VlooiVlerke - January 6, 2009 - 08:06
| Project: | Vertical Tabs |
| Version: | 6.x-1.0-beta1 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed |
Jump to:
Description
Hi, thanks this is great stuff.
Can you please make the location module work as a vertical tab. In this way you can select your location from a gmap and input the location info.
The location module is one of the messiest forms and is really difficult to hide, but your module will make it look great.
Thanks for the CCK fieldsets

#1
i also want to add that location cck fields don't show up inside as well - as well as echo the congrats - this is great for usability :)
#2
I was hoping it would work too but it is not. Location does not show up.
#3
Location module now shows up properly with #453898: Form elements without DIV wrapper excluded from tab pane, though we still don't support summary text describing what's inside the location field.
#4
The Location field still isn't showing up for me on 6.x-1.0-beta3. Is there something else I need to do?
#5
Hmm, well I assumed it would work. I don't use location.module, any patches to fix its behavior would be appreciated.
#6
I think I've pinpointed the problem. The location module formats its "fieldset" in the following way (trimmed down, of course):
<?php$form['locations'] = array(
'#type' => 'markup',
'#title' => 'Location',
0 => array(
'#type' => 'location_element',
'#title' => 'Location'
),
....
)
?>
With multiple inner "location_element" sets depending on how many locations the node has. The markup is then themed as a fieldset, and so is the location_element field type. So you can't detect the locations "fieldset" based on the type set in the form array. You could detect it by the #title, but seems like a hack (since you could potentially name other fieldsets Location).
#7
It turns out it's an easy solution. In a hook_form_alter(), change the location element to a fieldset:
<?phpfunction mymodule_form_alter(&$form, $form_state, $form_id) {
// For all node forms, change location to a fieldset so it'll
// be picked up by vertical tabs
if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && $form['locations']) {
$form['locations']['#type'] = 'fieldset';
}
}
?>
You could, I suppose, include this in the vertical_tabs.module, but it seems out of place.
#8
For others trying this, I seemed to be running into an issue where my module was weighted after vertical_tabs, and vertical_tabs needs to have a final run through the form after all fieldsets are set up (so it can add attributes, etc.)
So I imagine I could either lower the weight of my module, or, what I did, was just call the vertical tabs form alter again at the bottom of my form_alter:
vertical_tabs_form_alter($form, $form_state, $form_id);
#9
you could use the util module to change the weight of vertical tabs in your system too
#10
Can we ask the locations module to just use $form['locations']['#type'] = 'fieldset'?
#11
It actually looks like the latest code from location.module uses:
<?php'#type' => 'fieldset',
'#title' => format_plural($numforms, 'Location', 'Locations'),
'#tree' => TRUE,
'#attributes' => array('class' => 'locations'),
'#weight' => $settings['form']['weight'],
'#collapsible' => $settings['form']['collapsible'],
'#collapsed' => $settings['form']['collapsed'],
);
?>
so this should work just fine now.
#12
Automatically closed -- issue fixed for 2 weeks with no activity.
#13
erm...
I have the latest location and vertical tabs module installed, but I still can't select the location to insert it into the tabs...
any idea what to do?
#14
This has to be fixed somehow in CCK or Location module. There's likely nothing that we can or should do to special case this. I don't think this will work with Drupal 7's natural vertical tabs support either.
Leaving this postponed for now.