Drupal form api select elements returning integers instead of string

Submitted by alexmoreno on Wed, 07/03/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.

[gist:5920064]

categorias