开发者

How can I set a default value for the Location field of a location element in Drupal?

开发者 https://www.devze.com 2022-12-19 05:25 出处:网络
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,

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,

Benjy


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".


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号