Fixed null pointer error

Fixes an error when using the form_upload in a collection with prototypes, as the prototype object is null.

Also fixed the check in foreach to also check the form type parents.
Merge pull request #126 from kufi/patch-5

Fixed null pointer error