Vue-form-generator: Submit button does not call form validator

Created on 5 Oct 2018  ·  8Comments  ·  Source: vue-generators/vue-form-generator

  • Do you want to request a _feature_ or report a _bug_?
    Report a bug

  • What is the current behavior?
    Given 'validateBeforeSubmit' is true and form data does not pass validation rules
    When I click submit button, onSubmit function is called

  • Demo
    https://jsfiddle.net/nzkm7put/ (please check the result in console)

  • What is the expected behavior?
    onSubmit event should not be called

  • Please tell us about your environment:

    • Version: 2.3.1
    • Browser: Chrome 69
    • Language: ES6/7
  • Other information:

This may look like #434 but I'm using the built in onSubmit method, no form wrapper here so I think it is a different issue.

I have looked into the source code and found the call stack as below:

  • fieldSubmit.onClick()
  • formGroup.validate() <-- I think the problem is here, this should call the parent's validate() instead of child's one
  • abstractField@validate() <-- submit button does not have any validator, of course this will pass, that's why there is no error
bug need investigate

Most helpful comment

@zoul0813 @qduc Can confirm just upgraded now and fixed for me. thx

All 8 comments

Hello @qduc , you seem to know how to fix this, can you do a PR ?
We are all very busy, and that would help us tremendously. Thanks a lot !

Sure, I am glad to help, just want to make sure it is a bug and not an intended behavior.
I will give it a try then.

@qduc Oh, yes, I did not checked (sorry, I'm busy 😅 ).
In your fiddle, not error are triggered. I don't know why.
For the field, there is no problem (even though there should be one).
I'm sorry, I have no time to really look into it.
Can you investigate this absence of error ?

This is likely a bug introduced in 2.3.0 when we split formGenerator up and created formGroup - a lot of code relied on calling the parent.

We should probably inject some sort of “$vfg” property onto all the children for easier access to the main VFG structure?

I don't know, I fixed most of this in the v3, since the structure is no more about calling the parent, but sending event.
I'm sorry about this unforeseen consequence.

@qduc this should be fixed in 2.3.2, can you confirm and close the issue if so?

@zoul0813 @qduc Can confirm just upgraded now and fixed for me. thx

Yup, can confirm It's been fixed in 2.3.2.
Thanks for the release.

Was this page helpful?
0 / 5 - 0 ratings