Error when using Form Helper and select function
I'm working on a custom external form that will return pages edited based on a selected user and range of dates. I've got the user selector field working and the from/to date fields working, but I get the following error when I try to include a field to set the number of results per page:
Warning: Invalid argument supplied for foreach() in C:\wamp\www\concrete\concrete\helpers\form.php on line 329
I pulled up the form helper php file and found that line 329 is in the select function. This is the code I am using in my external form that is generating the error:
And here is line 329 in the form helper:
foreach($optionValues as $k => $value)
Can someone tell me what I'm doing wrong?
Here's the format for the select form helper:
$form->select($name, $options, $value, $tagAttributes) Outputs a select menu. The $options argument is a PHP array. The keys of the array will be used as the select option values, while the array values will be displayed in the menu. The $value parameter controls the initially checked select element. http://www.concrete5.org/documentation/developers/forms/standard-widgets/
It looks like in your code you've left out the array of options that it needs.
Hope this still helps.
$form->select(array(0 => '',1 => 'Fish',2 => 'Pork',5 => 'Fruit');, $categorySelection, $selectedKeyValue);
I posted a question about being confused and someone graciously explained all about the select ( getting the option list Array from db function )
Campbell, I think that you may have a different problem entirely. My *guess* is that $optionValues is just not an array at that point.
Try running a var_dump on the $optionValues, you may have to check to make sure that it is not null, or that it isn't false or whatever it is actually returning. I suspect you have an error in your code before you even make it to your helper functions.