Ticket #7439: added_files_to_get_form_method.diff

File added_files_to_get_form_method.diff, 2.2 KB (added by Damian Świstowski <damian@…>, 16 years ago)
  • django/contrib/formtools/wizard.py

     
    3030    def __repr__(self):
    3131        return "step: %d\nform_list: %s\ninitial_data: %s" % (self.step, self.form_list, self.initial)
    3232
    33     def get_form(self, step, data=None):
     33    def get_form(self, step, data=None, files=None):
    3434        "Helper method that returns the Form instance for the given step."
    35         return self.form_list[step](data, prefix=self.prefix_for_step(step), initial=self.initial.get(step, None))
     35        return self.form_list[step](data, files, prefix=self.prefix_for_step(step), initial=self.initial.get(step, None))
    3636
    3737    def num_steps(self):
    3838        "Helper method that returns the number of steps."
     
    5858        # For each previous step, verify the hash and process.
    5959        # TODO: Move "hash_%d" to a method to make it configurable.
    6060        for i in range(current_step):
    61             form = self.get_form(i, request.POST)
     61            form = self.get_form(i, request.POST, request.FILES)
    6262            if request.POST.get("hash_%d" % i, '') != self.security_hash(request, form):
    6363                return self.render_hash_failure(request, i)
    6464            self.process_step(request, form, i)
     
    6666        # Process the current step. If it's valid, go to the next step or call
    6767        # done(), depending on whether any steps remain.
    6868        if request.method == 'POST':
    69             form = self.get_form(current_step, request.POST)
     69            form = self.get_form(current_step, request.POST, request.FILES)
    7070        else:
    7171            form = self.get_form(current_step)
    7272        if form.is_valid():
     
    7777            # time, as a sanity check, and call done().
    7878            num = self.num_steps()
    7979            if next_step == num:
    80                 final_form_list = [self.get_form(i, request.POST) for i in range(num)]
     80                final_form_list = [self.get_form(i, request.POST, request.FILES) for i in range(num)]
    8181
    8282                # Validate all the forms. If any of them fail validation, that
    8383                # must mean the validator relied on some other input, such as
Back to Top