How to handle field objects like selects? #4036
Unanswered
sschneider-ihre-pvs
asked this question in
Q&A
Replies: 1 comment
-
Unfortunately, I cannot open the link or no content is displayed. Basically you can also equip a select field with a validator. The desired validator would look somehow like this:
To show a text for the picked value, you could implement a toString method or a function that displays the desired value from the object. Here is an example of how we implemented a select (here you could pass
In our case, the "options" are always string/value or number/value pairs, so we don't need to convert any object, but that wouldn't be a big step if it were the case |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So the question came up multiple times now. I am trying to make a better job of describing the problem.
All input field have one value, but in the case of something like selects, the visual representation might be consisting of more than one value.
Let's have a look at this example https://codepen.io/pen?&editors=101&prefill_data_id=9d16d04f-aa6e-4b94-962f-e8835e0f68d5
There is a select component that has a an object as value. And an array of objects as options. The value of the input field is just text while the inner input value of the component is the whole object.
My question now, is it possible to validate those objects with vee-validate and how?
For example, if I want to validate that there is a description and category is not 1 how would I do that?
Beta Was this translation helpful? Give feedback.
All reactions