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.
bug #13166 Fix a web profiler form issue with fields added to the form after the form was built (jakzal)

This PR was merged into the 2.6 branch.

Discussion
----------

Fix a web profiler form issue with fields added to the form after the form was built

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no, but not because of this PR
| Fixed tickets | #13155
| License       | MIT
| Doc PR        | -

This also make the check consistent with a similar check in this template made further down:
* check for `data.type_class`, instead of `data.type`
* check if `data.type_class` is defined rather than if it's empty

The problem doesn't exist in 2.5.

Commits
-------

1e794ca Check if a field type_class is defined before using it.