If you create a new node that has location information, the 'Location' fieldset appears in a box with scrollbars (see attached screenshot). With the Location module this just looks bad, but if you're also using the GMap module, it means the centre of the map is off-screen, making it very difficult to use.
The problem is that the "Longitude:" field's description text "If you want to supply your own ..." doesn't wrap, which forces the table to be so wide that it needs scrollbars.
If you look to the next field "Log Message:", you'll see its description text does wrap, so it looks fine.
I believe the "Longitude:" description wraps because of the "nowrap" in /modules/system/system.css :
tr.odd .form-item, tr.even .form-item {
margin-top: 0;
margin-bottom: 0;
white-space: nowrap;
}
I found the description text is set in the following routine in location.inc, passed in using the "$description" parameter:
function location_latlon_form($description = '', $prefilled_values = array()) {
$form = array();
$usegmap = (function_exists('gmap_set_location') && variable_get('location_usegmap', 1));
if ($usegmap) {
$form['map'] = array(); //reserve spot at top of form for map
}
$form['latitude'] = array(
'#type' => 'textfield',
'#title' => t('Latitude'),
'#default_value' => isset($prefilled_values['latitude']) ? $prefilled_values['latitude'] : '',
'#size' => 64,
'#maxlength' => 64
);
$form['longitude'] = array(
'#type' => 'textfield',
'#title' => t('Longitude'),
'#default_value' => isset($prefilled_values['longitude']) ? $prefilled_values['longitude'] : '',
'#size' => 64,
'#maxlength' => 64,
'#description' => $description,
);
if ($usegmap) {
$map_macro = variable_get('gmap_user_map', '[gmap|id=usermap|center=0,30|zoom=16|width=100%|height=400px]');
$form['map']['gmap']['#value'] = gmap_set_location($map_macro, $form, array('latitude'=>'latitude','longitude'=>'longitude'));
}
return $form;
}
I am using Drupal 5.2
So, I can see what's causing the problem, and there are several possible solutions including:
- does that css really need nowrap?
- quick hack, insert line breaks in the description text
- display the description text elsewhere, outside the area that has nowrap applied
- ... ?
Please can someone more familiar with Drupal help point me at what's the best way to fix this?
Thanks & regards, MrB
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | locationhack.jpg | 264.02 KB | bwv |
| #5 | patch_16.patch | 1.32 KB | mrb |
| nowrap-screenshot.jpg | 108.2 KB | mrb |
Comments
Comment #1
ray007 commentedYes, you need to add a css line for form-items in the location input form to have white-space: normal;
See http://drupal.org/node/132445#comment-279834 and http://drupal.org/node/132445#comment-279966
Comment #2
mrb commentedRay, thanks for the help. One more question - I see I need to update location.css, but when I looked at /node/add/page I couldn't see any mention of location.css. Is there another update I need to make to have the page consider location.css, or is that already taken care of somehow?
Regards, MrB
Comment #3
ray007 commentedI think location.css currently doesn't get loaded anywhere.
I think there was an issue for that somewhere, but I've added the css to the theme for now ...
Comment #4
mrb commentedThanks again, I'll follow up some more on the original 132445 you #mentioned.
Comment #5
mrb commentedIssue 132445 mentions the solution to this problem, but doesn't provide a patch - so here's a patch.
The patch:
- adds the two lines from http://drupal.org/node/132445 to location.css, but comments out the existing entries in the css file as specified in http://drupal.org/node/124314
- edits function location_latlon_form in location.inc to add a call to drupal_add_css(drupal_get_path('module', 'location') .'/location.css');
Regards, MrB
Comment #6
jiangxijay commentedSubscribe
Comment #7
thekk commentedsubscribing also
Comment #8
Foodster commentedI have tested the patch 16 with the latest dev, and it fixed the problem. please see the attachment for screenshot.
Comment #9
bdragon commentedhttp://drupal.org/node/136099 marked as duplicate.
Comment #10
mandclu commentedI still had an issue with the text not wrapping, at least in Firefox and Safari. Adding the following line to the CSS file fixed it for me:
Comment #11
scottrigby#10 worked for me as well (after the other solutions did not) - using a modified Garland theme btw
thanks!
Comment #12
marcoBauli commenteduhm...yes, the location.css stylesheet does not seem to get loaded..
inserting the class above in the theme style.css does the job though
Comment #13
smitty commentedThe form .locations .description { white-space: normal; } works fine for me too.
But also have a look at: http://drupal.org/node/213989
Comment #14
bdragon commentedMarking as dupe of http://drupal.org/node/231419.
Comment #15
delineas commentedIf your node add page doesn't load location.css add this to theme_location_form in location.theme:
Obviuosly n location.css add the line:
In Firefox works correctly
Comment #16
marcoBauli commented#15 worked as expected, thanks for that
also added the following to location.css to work around and hide the second fieldset (one inside each other):
#node-form fieldset.locations fieldset.location {
border: none;
padding: 0;
margin: 0;
}
#node-form fieldset.locations fieldset.location legend {
display: none;
}
Comment #17
bwv commentedThank you for the css fix, I'd been struggling with the location fieldset for some time.
I am developing a site using the location and gmap modules, and the only way I can get a registered user to be able to add a gmap marker is to grant permission to set latitude and longitude. Yet there is no need for these fields for my purposes, as the users can simply enter a postal code or manually place a marker on the map themselves.
Is there some means of hiding the latitude and longitude form fields? thanks
POSTSCRIPT: Figured this out by adding the following to my style.css:
#gmap-loc1-locpick_latitude0 {display: none;}
#gmap-loc1-locpick_longitude0 {display: none;}
By fiddling around with more style tags and hacking a little bit at the location.module and the location.inc files, I was able to display my location field as depicted in the attached image.