1

We've made a local copy of a site that is working fine in a staging environment but locally is getting the following error:

`Invalid argument supplied for foreach()`

Seemingly coming from craft/app/fieldtypes/BaseOptionsFieldtype.

Does anybody have any thoughts on what is causing this and how to resolve? Is happening both in the front-end and the admin area.

  • Can you enable devMode and share the full stack trace leading up to that error? – Brad Bell Jan 13 '17 at 22:19
  • So hit this problem again and cannot recall solution (payback for not posting up here …) Stack trace as follows: gist.github.com/cole007/a1fa47d90e4b3e125b608ecdf4944681 – Cole Henley Sep 7 '17 at 14:53
  • Regarding above, this follows an upgrade from 2.6.2950 to 2.6.2989 Any thoughts why above upgrade may be causing site not to load? Also of note is use of custom locales for this site – Cole Henley Sep 7 '17 at 16:07
  • Is there something past step #10 in the stack trace that tells you the template/line the error is coming from? – Brad Bell Sep 7 '17 at 16:34
  • updated gist for full stack trace – Cole Henley Sep 8 '17 at 8:10
2

Looking at the code where your errors is occurring (line 46 of craft/app/fieldtypes/BaseOptionsFieldType.php), it looks like you have either a Checkboxes or Multi-Select field whose options setting is somehow set, but not set to an array. Not sure how it could have gotten into that state, but that’s the only thing that would explain your error.

Try re-saving any Checkboxes/Multi-Select fields (or if you have any 3rd party field types installed that might be extending Craft’s BaseOptionsFieldType, that would be even more likely the culprit), ensuring they have at least one option set.

| improve this answer | |
  • Great, thanks Brandon. This has fixed the problem. A checkbox field was saved with a row but containing no options. Removing the row and saving has fixed. Cheers! – Cole Henley Sep 8 '17 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.