I wanna input data to database from Select Option Form. I used Laravel and Vue. This is my Form
<div class="form-group">
<label for="exampleFormControlSelect1">Pemilihan*</label>
<select class="form-control" id="electionId" name="electionId" v-model="electionIdSelected">
<option v-for="option in electionIdOptions" v-bind:value="option.value">{{option.text}}</option>
</select>
</div>
This is my Vue:
data() {
return{
electionIdSelected:'Please choose one',
electionIdOptions:[
{text: 'Presiden', value: 'ppwp'},
{text: 'DPRD Provinsi', value: 'pdpr'}
],
methods: {
onSubmit() {
axios.post('/psu/list/store', {
electionIdSelected: this.electionIdSelected,
}).then(response => {
this.electionIdSelected = ''
});
}
This is my Controller in Laravel:
public function store(){
$psu = new Psu;
$psu->jenis_pemilihan = request('electionId');
$psu->save();
}
Please help me to insert form Select option into database. I still got error. This is an Error Message:
null value in column "jenis_pemilihan" violates not-null constraint
Cant get value to Controller and Model.
}
– Rwd