Hi All,

I'm very new to Drupal and PHP. I'm building a form and I am trying to populate a drop down menu from a mysql table. Whenever I set the form field to '#type' => 'select', I get this message "warning: Invalid argument supplied for foreach() in C:\wamp\www\drupal\includes\form.inc on line 1428." when the page is build. If I change the #type to anything else (i.e. '#type' => 'textfield'), I don't get any errors. This field is nested in a formtable and formrow. Here is the code:

if (is_null($value2) != TRUE){
$form['cage']['cagetable']['row1']['cageselect1'] = array(
'#type' => 'select',
'#options' => $value2,
'#title' => 'Cage#',
'#prefix' => '

',
'#suffix' => '

',
);
}

I appreciate any ideas anyone has.

Thanks in advance,

Comments

chopper72’s picture

I have the same problem.

It only appears at the top of my GalleryAssist module section of the site?

Any ideas would also be helpful.

thanks

valedaw2’s picture

Hello I am getting a similar error:
warning: Invalid argument supplied for foreach() in /home4/swingbri/public_html/includes/form.inc on line 1429.

Anonymous’s picture

The value of $value2 should be an array of key-value pairs. See http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....

msan72’s picture

thx, that helped!
Sorry for the delay in responding.