Fix strange bug related to arrays and objects

All of a sudden out of nowhere I was getting errors for the Field class here saying invalid argument supplied for foreach() and other object vs. array errors. I made a few minor changes to how this method works and I think it should be fine.