[v3] Getting error props down a slot #3269
Answered
by
logaretm
gregorvoinov
asked this question in
Q&A
-
Hi, I have a component to wrap all the validation logic, but I can't push the error through the slot. But somehow theFormError works... //formrow
<template>
<div class="mb-4">
<v-validation-provider
v-slot="{ errors }"
:rules="validate"
>
<label>{{ label }}</label>
<slot
:onInput="onInput"
:error="errors.length ? true : false" //this doesn't work
/>
<vFormError
:errors="errors" //works my error message gets displayed
/>
</v-validation-provider>
</div>
</template>
<script>
import { ValidationProvider as vValidationProvider } from 'vee-validate'
import vTextfield from '@primitives/textfield'
export default {
components: {
vTextfield,
vFormError,
vValidationProvider
},
props: {
value: {
type: String,
default: '',
},
validate: {
type: String,
required: true,
}
},
}
</script> //textfield
<template>
<div>
<input @input="onInput"/>
</div>
</template>
<script>
export default {
props: {
value: {
type: String,
default: '',
},
error: {
type: Boolean,
default: false //doesn't get updated
}
},
data: {
}
methods: {
onInput(e) {
this.$emit('input', e.target.value)
}
}
}
</script> //form
<vFormRow validate="required" v-slot="{ onInput }">
<vTextfield @input="onInput"/>
</vFormRow> Why does error don't go through the slot? And is there also a way to avoid the v-slot="{ onInput }" @input="onInput" in the form? I'm using "vee-validate": "^3.4.5" & "vue": "^2.6.12", |
Beta Was this translation helpful? Give feedback.
Answered by
logaretm
Apr 18, 2021
Replies: 1 comment 3 replies
-
You didn't pass the
|
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
gregorvoinov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You didn't pass the
error
prop to the<TextField>
node, you should the same like you did withonInput
: