{% for form in formset.forms %}
<div class="elements">
{{form.as_ul}}
</div>
<input type="image" value="ADD" id="add_more">
{% endfor %}
here is what i have in js
$('#add_more').click(function(){
if($('.app-form').valid()){
cloneMore('div.ul:last','prefix');
}
});
and the rest is same as the reference this reference I'm trying to display forms when user goes for "ADD".when add is pressed it goes to the view as well as print one more form using jquery. in views.
def start(request):
qd = request.POST
ffact = formset_factory(ModelForm,extra=int(qd['prefix-TOTAL_FORMS']))
fset = ffact(qd,prefix='prefix')
if fset.is_valid():
return render_to_response('test.html',{'formset':fset})
else:
return render_to_response('test.html',{'formset':fset})
But jquery is resulting in additional form even if the submitted form is not valid,while view is resulting in the error messages for all the form-fields that are not valid. How can i make click action wait or somehow communicate with the views.py validation result and only then display extra form? Appreciate it.