Drupal form api select elements returning integers instead of string

Posted by alexmoreno on Wed, 03/07/2013 - 19:23

I always have the same problem when using select forms, and I always forget the solution.

Instead of returning an array, like: return $competitions; you have to return a drupal_map_assoc, like this: return drupal_map_assoc($competitions);

Otherwise, when selecting the form in hook_submit you will get a number, instead of a human readable string.

categorias: