You are here

function getlocations_location_taxonomize_field_widget_getlocations_fields_form_alter in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_location_taxonomize/getlocations_location_taxonomize.module \getlocations_location_taxonomize_field_widget_getlocations_fields_form_alter()

Implements hook_field_widget_WIDGET_TYPE_form_alter(). Here we add a process callback for every widget that is set to be taxonomized

File

modules/getlocations_location_taxonomize/getlocations_location_taxonomize.module, line 75
getlocations_location_taxonomize.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_location_taxonomize_field_widget_getlocations_fields_form_alter(&$element, &$form_state, $context) {

  // apply this only if we are in the right module and on a node-edit form
  if (_location_taxonomize_get_source() == LT_GETLOC_MODULE_ID && isset($context['form']['#node_edit_form'])) {

    // check field settings
    $taxonomize = $context['instance']['widget']['settings']['location_taxonomize'];

    // add a process function to getlocations_fields widget
    if ($taxonomize) {

      // notice avoidance
      if (!isset($element['#process'])) {
        $element['#process'] = array();
      }
      if (!in_array('getlocations_location_taxonomize_process_address', $element['#process'])) {
        $element['#process'][] = 'getlocations_location_taxonomize_process_address';
      }
    }
  }
}