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.