Dot-twigrenderer extends Twig with a function based on TwigTest that checks if each Form element is an instance of its class.
TwigTest
Form
public function getTests(): array;
{% if false not in getTests() %} {# your code #} {% endif %}