I have a set of forms that has two 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}} {% for form in formset1.forms %} {{ form }} {% endfor %} <input type="submit" value="Guardar" /> </div> </form>
The user must select one option in each form.
I tried require = True in forms.py, but if I select only one parameter, it works anyway.
It should not work if the user selects only an option. This is what I am trying to implement ..
Does anyone know how to do this?
Thanks in advance for your help!
pavid source share