Posted by afestein on October 22, 2009 at 5:05am
| Project: | UC Multiprice |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
Hi all,
The multiprice module works nicely with my site. However after creating a product and successfully entering the price details, if I go back and edit the product I get the error message:
warning: Invalid argument supplied for foreach() in /var/www/vhosts/clientwebsite.com/httpdocs/includes/form.inc on line 1428
The country drop down list is now blank with no options to select.
The offending line is the start of a foreach:
foreach ($choices as $key => $choice) {
Any ideas?
A
Comments
#1
As a hotfix, put this right before the foreach line:
<?phpif (!is_array($choices)) {
$choices = array();
}
?>
#2
i'm having the same issue. since i'm pretty much a noob, i'd just like to clarify: does that hotfix go in the form.inc file? because when i add it there, i still get the same error.
thanks in advance.
#3
help? anyone? pretty please. :)
#4
ok...i've experimented a bit. if i place this (sans the php tags):
if (!is_array($choices)) {
$choices = array();
}
before this:
foreach ($choices as $key => $choice) {
it fixes the error -- but i still don't have a country pull down.
thanks!
#5
i deleted the product that wasn't working and replaced it, and now everything's working, so please ignore my previous posts.
#6
Can we say that my hotfix solves the problem?
#7
yes, i believe it does. thank you! :)
#8
deleting one of the overrides also works to remove the error. i am only setting 2 of the available countries because of the bug which won't let you set just one override. but then you have to delete the other one to if you want to set the one you deleted again. i think this relates to the idea that the select box should be on "Please select" rather than a default country.
also i noticed that if you hit ENTER in the override form, you lose the image and the category assignments. i also don't think changing these overrides creates a new revision.
#9
I have noticed that the $countries array in hook_form_alter in uc_multiprice.module is passed to the $form array even when it is empty, i.e. when all countries had a entered a price and therefore no more country to be selected in the dropdown select box.
Attached patch checks the array before it goes and add the empty dropdown select box, and causes form.inc to complain.
#10
Closing. This is fixed in 2.x branch