You are here

function location_node_form_node_form_alter in Location 7.3

Implements hook_form_BASE_FORM_ID_alter().

Alter the node forms.

File

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

Code

function location_node_form_node_form_alter(&$form, &$form_state, $form_id) {

  // 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) {
    if (!empty($form_state['rebuild']) && !empty($form_state['values']['locations'])) {
      $locations = $form_state['values']['locations'];
    }
    else {
      $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']);
  }
}