在Drupal 8中,树枝的形状是这样的:
<form{{ attributes }}>
{{ children }}
</form>
我想显示所有字段,除了第一个。通常,我们使用without
过滤器,但是children
是字符串,因此无法使用。
<form{{ attributes }}>
{{ children|without('unwanted') }}
</form>
以小枝的形式,我们可以访问作为数组的element
变量。但是,无过滤器在这里仍然无法使用。
<form{{ attributes }}>
{{ element|without('unwanted') }}
</form>
[我知道我可以用{{ element.field }}
来显示所有字段,然后按1逐个显示。但是,如果我的表单有新字段,则在我更新表单树枝之前,将不会打印它们。我想保持动态的目的。
我不想想要更新php中的表单代码以使布局保持树枝状。
任何想法?
尝试一下:
{% for key in element|keys %}
{{ children|without(key) }}
{% endfor %}
希望成功...