You are here

function content_taxonomy_et_field_widget_form_alter in Content Taxonomy 7

Implements hook_field_widget_form_alter().

File

./content_taxonomy_et.module, line 34
Entity Translation integration for taxonomy terms.

Code

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

  // Change validation callback for autocompletes in order to fix the
  // retrieving of terms in the right language.
  if (in_array($context['instance']['widget']['type'], array(
    'taxonomy_autocomplete',
    'autocomplete_deluxe_taxonomy',
  ))) {
    foreach ($element['#element_validate'] as $key => $validate_callback) {
      if ($validate_callback == 'taxonomy_autocomplete_validate') {
        $element['#element_validate'][$key] = 'content_taxonomy_et_autocomplete_validate';
        break;
      }
    }
  }
}