Hi,
I'm using a formset with hidden fields in the forms and other required
fields. Those fields need to be initialized with some value. When I
try to validate the formset I get "required field" errors for those
other required fields. The formset apparently thinks that the
extraform is half filled (because of the initial data for the hidden
fields).
How can I avoid that behavior?
Let me give you an example (may not be completely right cause I'm
extracting the relevant parts of the original code):

class ItemForm(forms.Form):
    asignacion_id = forms.IntegerField(label="ID de la asignación",
required=True)
    gondola = forms.ModelChoiceField(Gondola.objects.all(),
required=True, label="Góndola")
    def clean_gondola(self)
         # Some code that uses asignacion_id

def myView(request):
    AsignacionItemFormset = formset_factory(ItemForm)
    formset = AsignacionItemFormset(request.POST, request.FILES)
    formset.is_valid() # Returns false with "required field" errors
for the extra form
    ...
    if not request.POST:
        formset = AsignacionItemFormset(initial=[{'asignacion_id':1,
'gondola':gon_id}])
        for form in formset.forms:
            form.fields['asignacion_id'].initial = 1 # To make sure
every asignacion_id is initialized to 1 (even the extra ones)

I hope someone can help me with these.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to