B
B
beduin012018-09-22 10:00:17
Vue.js
beduin01, 2018-09-22 10:00:17

How to setup form validation (Vue, Element)?

The code is 90% the same as the example from the documentation

https://jsfiddle.net/st56h3ky/
The only difference is that I have added a new nesting level. Namely, dynamicValidateFormnested in MainForm.
However, I am getting an error Cannot read property 'domains' of undefined.
The task is simple - to validate the nested object.
If you remove the nesting of MainForm, then everything works, but I need it with it.
I suspect that the problem is somewhere here: :prop="'domains.' + index + '.value'".

Answer the question

In order to leave comments, you need to log in

3 answer(s)
0
0xD34F, 2018-09-22
@beduin01

:model="MainForm"Should be instead :model="MainForm.dynamicValidateForm".
And :rules="rules"replace with :rules="rules.value".
UPD. Taken from the comments:

can I refer :model="MainForm"in the main form, and pass it to propsdynamicValidateForm

No problems:
:prop="`dynamicValidateForm.domains.${index}.value`"

L
Luke LikeSkywalker, 2018-09-22
@oolooq

Do you have all this code in .vue format in your project? If so, then data must be a function, not an object.

P
PloAl, 2018-09-22
@PloAl

There must be no objects inside data otherwise they will not be reactive, i.e. changes to objects inside data in vue are not tracked.
There can be arrays, but there are limitations with arrays, not all array methods are tracked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question