J
J
Jussss922021-07-16 12:02:49
Vue.js
Jussss92, 2021-07-16 12:02:49

How to check a bound attribute?

Hello.
I have a q-input component in the quasar framework
. They have a check (required) , to do the check you have to add :rules="[val => !!val || 'Field is required']"

That's the problem.
1.I have a variable that should add this rules if the variable is true.
I don't want to v-if the entire component because of this.
2. I need that if it is not required, it will change the new variable to false (so that I cannot save the form)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor, 2021-07-16
@IgorPI

This is solved with q-form
https://quasar.dev/vue-components/form

A
Aetae, 2021-07-16
@Aetae

Igor answered about sending the form .
And rules by condition - just like with any other variables, :rules is no different from any thread :vasya. Make a computed property that returns the desired value and put it in :rules.
You may also need quasar's reactive-rules property (or maybe not).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question