How can I set a default value for the Location field of a location element in Drupal?
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 ? $v开发者_StackOverflowanevents_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,
BenjyYou should be able to set the default for the location name by adding an element to your "fields" array with a key of "name".
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.
精彩评论