Hopefully this is clearer, and my last question in a long time!
Using PDO I have connected to an external DB, I can query this and return an array of values, Using html/php I can populate a standard select box. However I am unsure how to do this in the Form API, taking the array from the second paragraph, or do I query within the form item that produces the drop down? I want to take the name and the id, display the name. So that I can store the ID later.
$stmt = $conn->prepare("SELECT admin_name, adminuser_id FROM adminuser_tbl");
if ($stmt->execute()) {
$stmt->setFetchMode(PDO::FETCH_OBJ);
$user_list = array();
foreach ($stmt as $row) {
$user_list[$row->adminuser_id] = $row->admin_name;
}
}
$form['user_list']=array(
'#type'=>'select',
'#title' => t('Users'),
'#options' => $user_list,
'#multiple' => false,
'#attributes'=>array('size'=>4),
'#weight'=>8,
);