Jaco
Jaco

Reputation: 1694

CrispyForms: FormHelper - to get the </form> in another place, save two forms from the same model

When using FormHelper and calling the Form with {% crispy form %} it delivers a Form enclosed within <form> tags.

However, my Template is divided into two columns. First column holds the generated {% crispy form %}. Second column holds a hard-coded form. All entries are from the same model. First column is more "dynamic", second column is more "fixed".

I would like to be able to save both forms (both columns) at the same time, suggestively by putting both forms within the same <form> tags, such as below:

<form method="post">
{% csrf_token %}

{% block col8_content %}
{% crispy form %}
{% endblock col8_content %}
{% block col4_content %}
<div class="form-group row">
...
</div>

<input type="submit" value="Submit">
{% endblock col4_content %}

</form>

Q: Is there a way to combine the ability to easily create forms programmatically (FormHelper) together with manual elements?

Upvotes: 0

Views: 53

Answers (1)

art
art

Reputation: 1412

Set

self.helper.form_tag = False

You may then manually add an opening and closing form tags at the desired place.

It specifies if tags should be rendered when using a Layout. If set to False it renders the form without the tags. Defaults to True.

See https://django-crispy-forms.readthedocs.io/en/latest/form_helper.html

Upvotes: 1

Related Questions