-
Notifications
You must be signed in to change notification settings - Fork 413
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
form.commit({validate:false}) still validates individual fields #540
Comments
From the README:
In other words, I believe the If this behavior is really needed, perhaps introducing another option (e.g. |
@philfreo Thanks for breaking it down for me. I thought there was an intent that I wasn't picking up on. My usecase is this: I want to show users a rendered preview of their form values as they input data. Like a WYSIWG. (e.g. insert a headline in a form input, have it show up in a "preview pane" inside an I have a So if the On form submit, I will definitely validate and prevent submission if there are invalid fields. |
One idea is to move |
I think I see what you're getting at. It's an anti-pattern to commit dirty data to the model, and in a sense defeats the purpose of having validation schemas in the first place. Perhaps, I am the only exception who would like to commit dirty data to my model. However, I'm not a big fan of moving validation to the Backbone model's validate, as I lose out on backbone-form's schema pattern, which I really prefer, and ultimately on final submission, I want to use. Also, moving to a custom validator would be alright, but in practice, I'll probably end up writing custom validators for all my fields and then would have to lay some more code on to determine the state of a commit (final submission vs. preview render). So I'd either have to abstract Backbone-Form's validators or rewrite them. I'm going to submit a PR to see if there are thoughts on adding an option to |
How about having a different form + schema (in which you define which
fields you want to validate. e.g.: all except slug) for the preview pane?
Preview pane and normal form are backed by the same model.
…On Wed, Feb 8, 2017 at 1:46 AM, Charley Bodkin ***@***.***> wrote:
I think I see what you're getting at. It's an anti-pattern to commit dirty
data to the model, and in a sense defeats the purpose of having validation
schemas in the first place. Perhaps, I am the only exception who would like
to commit dirty data to my model.
However, I'm not a big fan of moving validation to the Backbone model's
validate, as I lose out on backbone-form's schema pattern, which I really
prefer, and ultimately on final submission, I want to use.
Also, moving to a custom validator would be alright, but in practice, I'll
probably end up writing custom validators for all my fields and then would
have to lay some more code on to determine the state of a commit (final
submission vs. preview render). So I'd either have to abstract
Backbone-Form's validators or rewrite them.
I'm going to submit a PR to see if there are thoughts on adding an option
to form.commit().
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#540 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAYAK2TAs-bvImthj1q39_Is1Xei1zl3ks5raRBkgaJpZM4L6I4s>
.
|
Don't write unvalidated data to the model. That's indeed an anti-pattern.
You never know which other view attached to the model expects a valid state
and would totally crash. Don't break that interface/contract.
On Wed, Feb 8, 2017 at 10:21 AM, Geert-Jan Brits (Clearskyabove) <
[email protected]> wrote:
… How about having a different form + schema (in which you define which
fields you want to validate. e.g.: all except slug) for the preview pane?
Preview pane and normal form are backed by the same model.
On Wed, Feb 8, 2017 at 1:46 AM, Charley Bodkin ***@***.***>
wrote:
> I think I see what you're getting at. It's an anti-pattern to commit
> dirty data to the model, and in a sense defeats the purpose of having
> validation schemas in the first place. Perhaps, I am the only exception who
> would like to commit dirty data to my model.
>
> However, I'm not a big fan of moving validation to the Backbone model's
> validate, as I lose out on backbone-form's schema pattern, which I really
> prefer, and ultimately on final submission, I want to use.
>
> Also, moving to a custom validator would be alright, but in practice,
> I'll probably end up writing custom validators for all my fields and then
> would have to lay some more code on to determine the state of a commit
> (final submission vs. preview render). So I'd either have to abstract
> Backbone-Form's validators or rewrite them.
>
> I'm going to submit a PR to see if there are thoughts on adding an option
> to form.commit().
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#540 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAYAK2TAs-bvImthj1q39_Is1Xei1zl3ks5raRBkgaJpZM4L6I4s>
> .
>
|
When I call
form.commit({validate: false})
I am receiving errors in response.It looks like individual fields are being validated with in form.validate() BEFORE checking if
skipModelValidate
is set.I'm going to file a PR shortly to check
skipModelValidate
before the individual fields are validated.This wasn't intentional, right? I'm not missing something important?
The text was updated successfully, but these errors were encountered: