Django Terms and Conditions form
django, django-forms
Solution
The confusing part is how embed a scrolling text field into the form with the TNC that is not editable.
This confusing part is easy: it's not a form element. It's just text.
Get your content somehow... say from a file as you suggest:
context = {}
with open('/terms-and-conditions.txt') as f:
context['terms'] = f.read()
Define a simple form:
class MyForm(forms.Form):
i_agree = forms.BooleanField()
Pass both to your template...
<div style="width:600px; height:300px; overflow-y:scroll;">
{% if form.errors %}
<h1>You must agree to the TNC</h1>
{% endif %}
<form method="post">
{{ form.as_p }}
<input type="submit" value="I agree to the TNC" />
</form>
</div>
Anything else is just a permutation of this simple pattern. Perhaps you use readonly textarea, a javascript warning, etc.
Problem
I'm trying to figure out the most elegant way to build a terms and conditions (TNC)form using django. The user has to agree to the TNC in order to continue. The confusing part is how embed a scrolling text field into the form with the TNC that is not editable. Then the user has to click the check box or the form is invalid. The TNC is a substantial doc and is located in a text file. Is there a way to load the text file and make that the content of the scrolling field. Any examples of this type of form or something similar? Thanks