Giter Site home page Giter Site logo

Comments (3)

richtier avatar richtier commented on May 30, 2024 1

here's a mixin. add it to the view

class PreventRevalidationMixin:
    NO_REVALIDATION_FIELD_NAMES = ['captcha']

    def process_step(self, form):
        for name in  self.NO_REVALIDATION_FIELD_NAMES:
           if name in form.fields:
               self.storage.extra_data[f'skip_validation{name}'] = True
        return super().process_step(form)

    def get_form(self, step=None, *args, **kwargs):
        form = super().get_form(step=step, *args, **kwargs)
        for name in self.NO_REVALIDATION_FIELD_NAMES:
           if name in form.fields and self.storage.extra_data.get(f'skip_validation{name}')
                del form.fields[name]
        return form

from django-formtools.

gchp avatar gchp commented on May 30, 2024

An interesting comment from the Trac discussion:

Changing the re-validation and making the last step a special case isn't a good idea. Think about a case when someone want's to add a captcha in the first step.. this would break too.

What do you think about a list of "don't re-validate" forms/steps? This would give people a way to mark specific steps as "validating once is fine, skip this form when re-validating everything for the done method".

I think this is a good point. The case given here is that the validation is failing because this user's case had a captcha in the last form. However, should the captcha have been in any of the other forms, it would have failed too. I like the suggestion of allowing certain forms to skip the final validation better than just skipping the re-validation of the last form. Interested to hear what others think, though.

from django-formtools.

vstoykov avatar vstoykov commented on May 30, 2024

We now have the same issue but we need to put the captcha on the first step.

As a workaround we will try to dynamically delete captcha field in get_form method if the form was already valid (there are data in the storage). If this works then generic solution can be made where you configure in which form which fields must be validated only once and then the wizard will automatically delete them when needed.

from django-formtools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.