Hi,

on my register form I use a Content Taxonomy field. The terms are translated and to assure that the terms are always listed in alphabetical order I use a little module which was created by some one else for a similar situation. But every time I activate this module a field which should be hidden until a value of another field is chosen is shown all the time. The field influencing the hidden field is not the one which is sorted by this module. maybe to help you this is the code from the module:

<?php

/**
 * Implementation of hook_form_alter().
 */
function sortcountries_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_register') {
    $form['#after_build'][] = '_sortcountries_after_build';
  }
}

/**
 * Helper function for uasort
 */
function sortcountries_strnatcasecmpspec($a, $b){
$chars = array('Ä'=>'A', 'Ö'=>'O', 'Ü'=>'U', 'ä'=>'a', 'ö'=>'o', 'ü'=>'u', 'ß'=>'s');
  $a = strtr($a, $chars);
  $b = strtr($b, $chars);
  return strnatcasecmp($a, $b);
}

/**
 * Sort the countries on the registration form
 */
function _sortcountries_after_build($form) {
  if (isset($form['group_address']['field_bn_country']['value']['#options'])) {
    uasort($form['group_address']['field_bn_country']['value']['#options'], 'sortcountries_strnatcasecmpspec');
  }
  return ($form);
}

Best,
Tobias

Comments

peterpoe’s picture

Issue summary: View changes
Status: Active » Fixed

Closing ancient support requests.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.