Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial form validations #66

Open
jace opened this issue Dec 8, 2014 · 3 comments
Open

Partial form validations #66

jace opened this issue Dec 8, 2014 · 3 comments

Comments

@jace
Copy link
Member

jace commented Dec 8, 2014

baseframe.forms.Form should provide two additional helper methods: validate_partial (and validate_on_submit_partial) and populate_obj_partial that validate and populate only the fields present in request.form (or submitted form).

This will allow building views with inline edit, submitting only whatever has changed while reusing existing forms.

Since this does mess with forms that override validate to do full form validation, or have custom cross-field validation (like the WTForms EqualTo validator for password fields), there should be a mechanism to protect them:

  1. Forms must explicitly declare themselves partial validation-safe, or
  2. Apps must avoid doing partial validations on problem forms, or
  3. Unsafe validators must declare themselves so, preventing partial validations on those fields.
@jace
Copy link
Member Author

jace commented Feb 11, 2015

WTForms provides two processing methods for form fields: process and process_formdata. The first gets the entire form and (only) the corresponding attribute in the object, and internally calls process_formdata or process_data based on whether a form or object was received. For partial validation to work, we need to work out which keys in the form map to which fields and call them separately (and ignore the already processed blank field.data present in other fields -- field.process gets called when a form is instantiated, so it's too late for validate_partial).

This is a problem for fields like Baseframe's RadioMatrixField, since they override process and ignore their own field name when mapping from the form to contained fields. The only way this can work is if we whitelist all the fields that are known safe for partial validations.

@jace
Copy link
Member Author

jace commented Feb 12, 2015

Since we've now adopted Parsley.js for client-side validations (#57), Parsley's Remote plugin may help. It's meant for submitting a field at a time for validations.

@jace
Copy link
Member Author

jace commented Nov 21, 2017

We should integrate view-level support in CrudView (#80).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant