1. Guillaume Piot
  2. Cotidia Contact Form

Commits

Guillaume Piot  committed 48c6fbd

Added get initial

  • Participants
  • Parent commits 0bbc583
  • Branches master

Comments (0)

Files changed (1)

File contact_form/templatetags/contact_form_tags.py

View file
 def contact_form(context):
 	request = context['request']
 
-	form = ContactForm()
+	initial = {}
+	if request.GET.get('name', False):
+		initial['name'] = request.GET['name']
+	if request.GET.get('email', False):
+		initial['email'] = request.GET['email']
+	if request.GET.get('tel', False):
+		initial['tel'] = request.GET['tel']
+	if request.GET.get('message', False):
+		initial['message'] = request.GET['message']
+
+	form = ContactForm(initial=initial)
 	success = False
 
 	if request.method == 'POST':
 
+
 		form = ContactForm(data=request.POST)
 		if form.is_valid():
 			form.save()