2.4.7
Windows 10 Chrome
2.5.17
https://jsfiddle.net/st56h3ky/
I need to need to validate nested form data in Vue Element. The example ( https://element.eleme.io/#/en-US/component/form#delete-or-add-form-items-dynamically ) is pretty same with my code. The only difference that dynamicValidateForm is wrapped in MainForm
Expected working nested form with validation
I am getting error Error: please transfer a valid prop path to form item!"
Validation can not work with array index.
It's seems that this variant is working:
:prop="'dynamicValidateForm' + '.domains.' + index + '.value'"
:rules="rules.value"
Full code:
<el-form :model="MainForm" ref="MainForm" label-width="120px" class="demo-dynamic">
<el-form-item
v-for="(domain, index) in MainForm.dynamicValidateForm.domains"
:label="'Domain' + index"
:key="domain.key"
:prop="'dynamicValidateForm' + '.domains.' + index + '.value'"
:rules="rules.value"
>
<el-input v-model="domain.value"></el-input><el-button @click.prevent="removeDomain(domain)">Delete</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm('MainForm')">Submit</el-button>
<el-button @click="addDomain">New domain</el-button>
<el-button @click="resetForm('MainForm')">Reset</el-button>
</el-form-item>
</el-form>
:prop="'dynamicValidateForm.domains.' + index + '.value'"
Duplicate of #11112
Most helpful comment