<div class="alert">{{ form.message }}</div>

<form name="{{ form.name }}"
      action="{{ uri.rootUrl ~ (form.action|default(page.route)) }}"
      method="{{ form.method|upper|default('POST') }}">
{% for field in form.fields %}
    {% set value = form.value(field.name) %}
    <div>
        {% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
    </div>
{% endfor %}

	<div class="buttons">
	{% for button in form.buttons %}
	    <button class="button" type="{{ button.type|default('submit') }}">{{ button.value|default('Submit') }}</button>
	{% endfor %}
	</div>
</form>

<div class="alert">{{ form.message }}</div>

<form name="{{ form.name }}"
      action="{{ uri.rootUrl ~ (form.action|default(page.route)) }}"
      method="{{ form.method|upper|default('POST') }}">
{% for field in form.fields %}
    {% set value = form.value(field.name) %}
    <div>
        {% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
    </div>
{% endfor %}

	<div class="buttons">
	{% for button in form.buttons %}
	    <button class="button" type="{{ button.type|default('submit') }}">{{ button.value|default('Submit') }}</button>
	{% endfor %}
	</div>
	
	{{ nonce_field('form', 'form-nonce') }}

</form>

Add form nonce to custom form code
Add form nonce to custom form code