I am using a Twig template to render a form that has a variable number of elements.
Each element’s key in the form is sequential integer.
So in my template, I can do this:
{% for item in form|children %} {{ item }} {% endfor %}
However, then I have a broken form, because there’s no <FORM>
HTML element, or the form ID for submission.
I’ve looked at twig templates for forms in core, but they all work with fixed elements, so they’re able to do something like this, seen in modules/content_moderation/templates/entity-moderation-form.html.twig
:
{{ form|without('current', 'new_state', 'revision_log', 'submit') }}