Timeline for How to populate a dropdown list from array in FORM API
Current License: CC BY-SA 3.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 1, 2013 at 12:57 | vote | accept | Tom | ||
Aug 1, 2013 at 12:57 | comment | added | Tom | @Mołot I edited the question, I was missing the PDO fetch. | |
Aug 1, 2013 at 12:30 | comment | added | Mołot |
@Tom dpr($user_list) and dpr($row) after each iteration (well, cut it to about 5 database rows for testing) and we might be able to tell something. Also - are you sure your watchdog does not report connection errors?
|
|
Aug 1, 2013 at 11:27 | comment | added | Tom | @Clive I have edited the question, with what I have tried, I'm getting a blank box? I'm obviously doing something wrong? the array $user_list is empty | |
Aug 1, 2013 at 11:24 | history | edited | Mołot | CC BY-SA 3.0 |
added 39 characters in body
|
Aug 1, 2013 at 11:21 | comment | added | Mołot | @Clive Good to know. I'm yet to encounter a situation where I will not need a loop anyway ;) If I will, I hope I'll remember this. | |
Aug 1, 2013 at 11:20 | comment | added | Clive♦ |
We have fetchAllKeyed() which is functionality equivalent :)
|
|
Aug 1, 2013 at 11:19 | history | edited | Mołot | CC BY-SA 3.0 |
added 39 characters in body
|
Aug 1, 2013 at 11:17 | comment | added | Mołot | @Clive I usually make some operations in the loop, too. And Drupal's DB api don't have PDO::FETCH_KEY_PAIR as far as I remember... So I just forgot, my mistake. | |
Aug 1, 2013 at 11:14 | history | edited | Clive♦ | CC BY-SA 3.0 |
added 5 characters in body
|
Aug 1, 2013 at 11:12 | comment | added | Clive♦ |
Or even quicker: $user_list = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); (would mean the query parameters need to be reversed to user_id, name )
|
|
Aug 1, 2013 at 11:09 | history | answered | Mołot | CC BY-SA 3.0 |