{% load cms_tags %}

{# This is a very nasty hack to redirect the user #}
{% if form_success_url %}
<script type="text/javascript">
    window.location.replace("{{ form_success_url }}");
</script>
{% endif %}

<form class="aldryn-forms-form{% if instance.custom_classes %} {{ instance.custom_classes }}{% endif %}" action="." method="POST">
	{% csrf_token %}
	{% for field in form.hidden_fields %}
	{{ field }}
	{% endfor %}
	<ul>
		{% for error in form.non_field_errors %}
			<li class="aldryn-forms-error aldryn-forms-global-error">
				{{ error }}
			</li>
		{% endfor %}
		{% for plugin in instance.child_plugin_instances %}
			{% render_plugin plugin %}
		{% endfor %}
	</ul>
</form>
