You are here

function location_node_form_alter in Location 7.4

Same name and namespace in other branches
  1. 5.3 location_node.module \location_node_form_alter()
  2. 6.3 location_node.module \location_node_form_alter()

Implementation of hook_form_alter().

File

./location_node.module, line 11
Associate locations with nodes.

Code

function location_node_form_alter(&$form, &$form_state, $form_id) {
  if (!empty($form['#node_edit_form'])) {

    // Add the Location fields on the Node edit form
    $node = $form['#node'];
    $settings = variable_get('location_settings_node_' . $node->type, array());
    if (isset($settings['multiple']['max']) && $settings['multiple']['max'] > 0) {
      $locations = isset($node->locations) ? $node->locations : array();
      $form['locations'] = location_form($settings, $locations);
      $form['locations']['#group'] = 'additional_settings';
      unset($form['locations']['collapsible']);
      unset($form['locations']['collapsed']);
    }
  }
}