i have this input:
<div class="d-flex justify-content-between align-items-center">
<label for="patymentTerms">Payment Terms</label>
<b-form-checkbox id="patymentTerms" :checked="true" switch v-model="rForm.payment_terms" />
</div>
and this is the data:
data() {
return {
rForm: {
payment_terms: "",
},
};
},
i am able to store data and other inputs in database but i'm a bit confused of how can i return false or true to of this input
You can do it like this:
data() {
return {
rForm: {
payment_terms: 0,
},
};
on on your controller:
$payment_terms = $request->payment_terms == 1 ? 1 : 0;
You can simply achieve this by using only v-model.
Demo :
new Vue({
el: "#app",
data() {
return {
rForm: {
payment_terms: false,
}
}
},
methods: {
getCheckboxValue() {
console.log(this.rForm.payment_terms);
}
}
});
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap@4.5.3/dist/css/bootstrap.min.css" />
<script src="https://unpkg.com/vue@2.6.12/dist/vue.min.js"></script>
<script src="https://unpkg.com/bootstrap-vue@2.21.2/dist/bootstrap-vue.min.js"></script>
<div id="app">
<label for="patymentTerms">Payment Terms</label>
<b-form-checkbox v-model="rForm.payment_terms" @change="getCheckboxValue" />
</div>
SOLUTION:
I forgot to change the input to boolean in MySQL and Controller
so this solved my problem:
View:
payment_terms: Boolean,
Controller:
'payment_terms' => 'required|boolean',
Thanks everyone