views:

87

answers:

1

Hi,

I am in the process of making a webapp, and this webapp needs to have a form wizard. The wizard consists of 3 ModelForms, and it works flawlessly. But I need the second form to be a "edit form". That is, i need it to be a form that is passed an instance.

How can you do this with a form wizard? How do you pass in an instance of a model? I see that the FormWizard class has a get_form method, but isnt there a documented way to use the formwizard for editing/reviewing of data?

A: 

you can use formwizard class in a view and pass initial there, something like:

def edit(request):
    initial = {0: {'field1':'value1'}}
    return FormWizard([form, some_other_form], initial=initial)

where initial should be a dict with keys equal to steps and values are dicts of data just like for usual form.

Dmitry Shevchenko
Are sure about this? I have already tried that and it fails. You get an error saying: "'EditingForm' object is not callable".
Espen Christensen
uh my bad indeed you can't toss instance there :/ updated my answer
Dmitry Shevchenko
I don't think the middleware likes the "return FormWizard" thing, because formWizards don't have a status_code and at some point there's a checks for status_code == 400. I get errors when I try this
hendrixski
return FormWizard won't work, you need to return instance
Dmitry Shevchenko