Created
July 3, 2013 16:24
-
-
Save alex-moreno/5920064 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Competition list | |
* | |
*/ | |
function mymodule_competitions_results_list_competitions(){ | |
// Main sql | |
$sql = "SELECT * FROM `node` WHERE type='webform' LIMIT 0,30 "; | |
$result = db_query($sql); | |
// WE STORE THEM (FULL NODE) IN AN ARRAY TO BE RETURNED | |
while( $row = db_fetch_array( $result ) ) { | |
$competitions[] = $row['title']; | |
} | |
return drupal_map_assoc($competitions); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment