You are here

function location_node_form_alter in Location 5.3

Same name and namespace in other branches
  1. 6.3 location_node.module \location_node_form_alter()
  2. 7.4 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_id, &$form) {
  switch ($form_id) {
    case 'node_type_form':

      // Add the options to the Node Type form
      _location_node_type_form_alter($form_id, $form);
      break;
  }
  if (isset($form['type']['#value']) && $form['type']['#value'] . '_node_form' == $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) {
      $locations = isset($node->locations) ? $node->locations : array();
      $form['locations'] = location_form($settings, $locations);
    }
  }
}