Hi All I am using betterselect module. I have a custom form, part of code looks as below.
$locations_arr = array( '0' => t('-Select-'), '1' => t('Anywhere in India'), '2' => t('Anywhere in North India'), '3' => t('Anywhere in South India'),);
$form['name']['prefloc'] = array( '#type' => 'select', '#multiple' => TRUE, '#title' => t('Preferred Work Location'), '#options' => locations_arr, ); When I access the form page, I get warning "warning: Invalid argument supplied for foreach() in C:\http\wamp\www\netcloudjobs\sites\all\modules\betterselect\betterselect.module on line 104.".
Please let me know, where I am wrong and how to fix this issue.
Thanks Kamal NECS, Bangalore
'#options' => locations_arr, -> '#options' => $locations_arr,
2012/8/26 Kamal Palei palei.kamal@gmail.com:
Hi All I am using betterselect module. I have a custom form, part of code looks as below.
$locations_arr = array( '0' => t('-Select-'), '1' => t('Anywhere in India'), '2' => t('Anywhere in North India'), '3' => t('Anywhere in South India'),);
$form['name']['prefloc'] = array( '#type' => 'select', '#multiple' => TRUE, '#title' => t('Preferred Work Location'), '#options' => locations_arr, ); When I access the form page, I get warning "warning: Invalid argument supplied for foreach() in C:\http\wamp\www\netcloudjobs\sites\all\modules\betterselect\betterselect.module on line 104.".
Please let me know, where I am wrong and how to fix this issue.
Thanks Kamal NECS, Bangalore
-- [ Drupal support list | http://lists.drupal.org/ ]
Hi Arto Pastinen That was a type error. I had tried that ($locations_arr), but it did not work.
In my custom .module file
I have declared array at starting of file.
In _form API, I was trying to use array. It did not work.
I got a work around, I wrote a function that returns the array, and in code (in multiple functions), I am just calling the function that returns the array and using it.
Thanks Kamal
On Sun, Aug 26, 2012 at 4:14 PM, Arto Pastinen arto.pastinen@gmail.comwrote:
'#options' => locations_arr, -> '#options' => $locations_arr,
2012/8/26 Kamal Palei palei.kamal@gmail.com:
Hi All I am using betterselect module. I have a custom form, part of code looks
as
below.
$locations_arr = array( '0' => t('-Select-'), '1' => t('Anywhere in India'), '2' => t('Anywhere in North India'), '3' => t('Anywhere in South India'),);
$form['name']['prefloc'] = array( '#type' => 'select', '#multiple' => TRUE, '#title' => t('Preferred Work Location'), '#options' => locations_arr, ); When I access the form page, I get warning "warning: Invalid argument supplied for foreach() in
C:\http\wamp\www\netcloudjobs\sites\all\modules\betterselect\betterselect.module
on line 104.".
Please let me know, where I am wrong and how to fix this issue.
Thanks Kamal NECS, Bangalore
-- [ Drupal support list | http://lists.drupal.org/ ]
-- regards, Arto Pastinen GPG key on wwwkeys.de.pgp.net, FP: DF04 1644 0812 9633 306F 9CCA 660C 285F 501C 8312 -- [ Drupal support list | http://lists.drupal.org/ ]