Check if a field type_class is defined before using it.

This make the check consistent with a similar check in this template made further down, and fixes an issue with fields added to the form after the form was built.