views:

93

answers:

2

Hi,

I am trying to set a default value for the location field of a location element in a Drupal form. I have figured out how to set default values for all of the other fields (address, additional address, city, state, zip, country) but can't figure out how to set the actual location default. My code:

$settings = array(
  'multiple' => array('min' => 0, 'add' => 1, 'max' => 1),
  'form' => array(
    'collapsible' => FALSE,
    'collapsed' => FALSE,
    'fields' => array(
      'country' => array('collect' => 4, 'weight' => 14, 'default' => variable_get('location_default_country', 'us')),
      'street' => array('collect' => 4, 'default' => $vanevents_node['address']),
      'additional' => array('collect' => 4, 'default' => $vanevents_node['address2']),
      'city' => array('collect' => 1, 'default' => $vanevents_node['city']),
      'province' => array('collect' => 1, 'default' => $vanevents_node['state']),
      'postal_code' => array('collect' => 2, 'default' => $vanevents_node['zip'] > 0 ? $vanevents_node['zip'] : ""),
      'locpick' => array('collect' => 0),
      'is_primary' => array('default' => 1),
    ),
  ),
);
location_normalize_settings($settings);
$form['vanevents_createevent']['locations'] = location_form($settings, array());

Anyone know how to set the default value for the actual location field? I'm sure it's easy but I can't figure it out/find it in the docs for the Location module's API.

TIA,
Benjy

A: 

Assuming this is about a location CCK field added to a certain content type: You can set the default values for Location name, Street, Additional, Country, Latitude and Longitude on the configure page of that field.

marcvangend
Ah, not quite - the above code is embedded in my hook_form() function and I need to be able to set a default for each node dynamically. How could I do that?Thanks very much,Benjy
benjy
+1  A: 

You should be able to set the default for the location name by adding an element to your "fields" array with a key of "name".

cwegrzyn
You are truly a god among men.
benjy