Skip to content

Radio Group, can't use field errors from child component #3871

Answered by logaretm
zkulbeda asked this question in Q&A
Discussion options

You must be logged in to vote

I think you can reverse the relationship between RadioInput and RadioGroup. Since RadioInput cannot be used without a corresponding RadioGroup then useField should be called in RadioGroup. The RadioInput components would only just change their group parent value using either custom injections, actually vee-validate gives you a context key you can use to do that.

I have something working along those lines, maybe it will work for you in that case.

// RadioGroup setup
import { useField } from 'vee-validate';
// No need to provide `type=radio` since this is not an individual radio item
// now radio group have access to errors and can display them.
const field = useField('name', null)

// Radi…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by zkulbeda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants