I have form input using Vue on my project , but in my input 1 field select box cannot record on my sending input ( always null) , another filed like tipe text , number its work , but only this select box cannot record on input
its my input
// this field select cant record ( always give null ) ,
<div class="field">
<div class="select">
<select name="anak_id">
<option v-for="(invent, id) in kod_rek" :key="id" :value="id">
{{ invent }}
</option>
</select>
</div>
</div>
// and this field work normally
<div class="field">
<label for="kode_rekening">kode rekening</label>
<input
type="text"
id="kode_rekening"
class="input"
:value="userData.kode_rekening"
@input="userData.kode_rekening = $event.target.value"
>
<div v-if="errors && errors.kode_rekening" class="text-danger">{{ errors.kode_rekening[0] }}</div>
</div>
and on this export default
export default {
data(){
return{
fields: {},
errors: {},
userData:{
anak_id:'',
kode_rekening:'',
uraian:'',
anggaran:'',
},
kod_rek:{},
isSubmited: true,
}
},
created(){
axios.get('/users/get_data_turunan_anak').then((res)=>{
this.kod_rek = res.data
// console.log(res.data)
}).catch((err) => {
console.log(err)
});
}
methods:{
submited(){
this.isSubmited = true;
},
submit() {
this.errors = {};
axios.post('/users/input_turunan_anak', this.userData).then(response => {
window.location = response.data.redirect;
}).catch(error => {
if (error.response.status === 422) {
this.errors = error.response.data.errors || {};
}
});
},
},
only my select box cant storing on this input , whats this problem and my network having error
message: "SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'anak_id' cannot be null (SQL: insert into
turunan_anak(anak_id,kode_rekening,uraian,anggaran,updated_at,created_at)