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.