Element: [Bug Report] Validation form - Does not work if prop has a different name

Created on 6 Jun 2017  ·  7Comments  ·  Source: ElemeFE/element

Element UI version

1.3.5

OS/Browsers version

macOS

Vue version

2.3.3

Reproduction Link

https://jsfiddle.net/4b7v39d9/

Steps to reproduce

1 - Type something that is not a email

2 - Change the rule to required = true, -> Everything is working fine

3- Change the name of the rule and of the prop to name so it matches the v-model and turn off the required to false ----> Working fine

What is Expected?

Form should not submit

What is actually happening?

Form Submit

Most helpful comment

'prop' must match field path of form's model, and rule's field/property key.

https://jsfiddle.net/6cuuro4w/

All 7 comments

I'm not sure I understand what your problem is. The correct usage: https://jsfiddle.net/4b7v39d9/1/

Why would you use different names for prop and v-model?

I thought such a situation would work. Let's say you have a deep nested object for your v-model. It might be a good idea to have a shortcut for the props and the rules

For deep nested object, you may find inspiration from this example: http://element.eleme.io/#/en-US/component/form#delete-or-add-form-items-dynamically

Sorry to re-address this closed issue, but I'm not sure if the following is expected behaviour or not.

https://jsfiddle.net/7at1v1bL/1/

As you can see with this relatively simple use case a field might have a couple properties that need to be reactive. In this scenario, it looks like the validation gets triggered but can never be resolved even after entering a valid email address. Is it possible to achieve validation in this example? If not, an example fiddle with the same use case working would be very much appreciated.

Just to be clear I tried changing the prop to "ruleForm.email.value", "email.value", and "email" but no luck.

Thanks for your time!

'prop' must match field path of form's model, and rule's field/property key.

https://jsfiddle.net/6cuuro4w/

Thanks for your reply @wacky6, however, it doesn't appear that validation is occurring when I click submit when no value has been entered. Can you confirm that is the case for you?

Was this page helpful?
0 / 5 - 0 ratings