Hi,

I developed a module to accept name, email, city, country, age range and languages spoken. out of these, languages spoken and age range are select boxes ... i have no problem with the age range select box (every entry shows up) but the languages spoken select box is displayed blank and i get a warning:

warning: Invalid argument supplied for foreach() in /home/media/public_html/includes/form.inc on line 671.

Any pointers ??? I hope someone can help me out with this ..

thanks ..

Comments

nevets’s picture

When you build the select for languages spoken you should be setting '#options' to an array containing the list of spoken languages. My quess is you are either not set '#options' or setting it incorrectly.

pratyk’s picture

hi,

the options array wasn't set up correctly. i got that part on but now, when i submit the form,

i get this warning:

warning: implode() [function.implode]:
Bad arguments. in /home/media/public_html/modules/cyber_register.module on line 239.

I used the implode function to get the values selected in the select box ..

$agvtxt = implode("\r\n", $form_values['age_level']);

i am completely baffled by this ..

nevets’s picture

If you age_level represents a single value, you can retrieve that using $form_values['age_level'], if it can contain multiple values I use something like

foreach ( (array)$form_values['age_level'] as $index => $value ) {
  // Do something with $value
}

If you are trying to store the array as a string casting the value to an array will cover the case of no or one response

$agvtxt = implode("\r\n", (array)$form_values['age_level']);