You are here

function location_taxonomize_af_field_widget_addressfield_standard_form_alter in Location Taxonomize 7.2

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

File

location_taxonomize_af/location_taxonomize_af.module, line 64

Code

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

  // check if this module is enabled as the current source
  if (_location_taxonomize_get_source() != LT_AF_MODULE_ID) {
    return;
  }

  // apply this only if we are on a node-edit form
  if (!isset($context['form']['#node_edit_form'])) {
    return;
  }

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

  // add a process function to addressfield widgets
  if ($taxonomize) {
    if (!in_array('location_taxonomize_af_process_address', $element['#process'])) {
      $element['#process'][] = 'location_taxonomize_af_process_address';
    }
  }
}