Comments (3)
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.
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.
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)
- Revisiting a form step does not refresh the return from storage.get_step_files(). HOT 2
- FormWizard doesn't work with FormSet/formset_factory()
- How do I display per field errors? HOT 1
- Release version 2.4 HOT 2
- Infinite Recursion possible in 2.4 HOT 41
- Document how to test form wizards
- update links
- Invalid CSRF Fail HOT 1
- Question: Best way to make request after form submission HOT 1
- how is the name of an html element created and how do i get that from the form wizard?
- Release new version with Django 4.2 LTS support HOT 4
- Access URL Parameters in WizardView Templates
- README: irc archives no longer exist HOT 2
- dependent fields is not working django-select2 HOT 1
- Exception Type: KeyError at ... HOT 1
- pkg_resources in current release (2.4.1) clashes with python 3.12 default venv HOT 2
- Build produces a version 0.0.0 HOT 1
- Attempting to implement conditional views generates the error RecursionError: maximum recursion depth exceeded HOT 1
- Regression from #168: unable to call get_cleaned_data_for_step on conditionally step
- ModelForm + Crispy Forms + Additional Field: clean_FIELD does not receive expeceted data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-formtools.