django - both forms in formset need to be selected -


i have formset have 2 forms.

forms:

class presclinicform(forms.form):     _names = list(presclinic.objects.values_list('pres_clinic_id', 'pres_clinic_name'))     _names.append(["new", u'nova entrada'])      pres_name = forms.choicefield(widget=radioselect(), choices=_names, label=         "", required=true)  presclinicformset = formset_factory(presclinicform, extra=2) 

views:

if request.method == 'post':     formset1 = presclinicformset(request.post, request.files, prefix='pres_clinic')     if formset1.is_valid():         choice = formset1.cleaned_data     return render_to_response('template.html', {'options': options}) 

template:

    <form method="post" action="">     <div>     {{ formset1.management_form}}         {% form in formset1.forms %}             {{ form }}         {% endfor %}         <input type="submit" value="guardar" />     </div>     </form>    

the user has select 1 option in each form.
tried required=true forms.py if select 1 option, works anyway..

it shouldn't work if user select option. that's trying implement..

does knows how this?

thanks in advance help!

you can use matthew flanagan's code requiring @ least 1 form in formset valid starting point , integrate workflow: http://wadofstuff.blogspot.com/2009/08/requiring-at-least-one-inline-formset.html

hope helps out.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -