devjin0617 / vue2-admin-lte

:bar_chart: adminLTE to vuejs v2.x converting project
https://devjin0617.github.io/vue2-admin-lte
MIT License
1.07k stars 324 forks source link

VAInput passing undefined value, how to pass forminput values ? #63

Closed amrigo closed 5 years ago

amrigo commented 5 years ago

I am new to Vue js

I have a vuejs2-admin-lte aplication.

I try to record in the database using an axios call,

The text field input is named question,

I look at the console and see the variable is undefined.

It uses the VAInput component.

What step is missing, to pass the html input value to an axios call and save the record ?

Here is the html :

<va-input v-if="field.type === 'input'" :isHorizontal="true" :title="field.label" :placeholder="field.label" type="text" class="col-md-12" :model="formInput[index]" :isDisabled="field.formReadOnly" @updateComponent="formInput[index] = $event">

Here is the data for the question field:

data () {
    return {                            
        fields : {              
                  Question:{
            label: 'Question',
                    sortable: false,
                    type    : 'input',
                    tdClass : 'text-left',
                    formReadOnly : false,
                    mask: ''  
                }
            }
    }
And the save method :

```

formSave() {

        this.saveButton = true;
        this.formLoading= true;
        this.axios.post('Questions/save',
        {
            "data"         : { Id    : this.formInput.Id,
                               Question: this.formInput.Question,
                               Active : this.formInput.Active 
                            },
            "email"        : this.email,
            "session"       : this.session,
            "route"        : this.$route.name,
        }).then((response) => {
            if(response.data === 1){
                this.getList();
                this.formEnable = false;
            }
        }).catch((error) => {
            if ( error.response.status == "403" ) {
                location.href = '/login';
            }
            if(typeof error.response == "undefined"){
                alert("Error.");
            }
        });
        this.formLoading= false;
        this.saveButton = false;
    },


The active field is populated but the question field is not populated.

What can it be or there is any example of a save operation i can follow ?
amrigo commented 5 years ago

this problem was solved