Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

323
Views
Get Correctly Formatted key:value Pair From Vue Formulate Form

PROBLEM I receive JSON data from an API in the format -

"foo":{"bar":{"id":"B","description":"BSK"},"doe":{"id":"D","description":"DOE"}}

I have recently made a form using Vue Formulate and have found it to be incredibly helpful so far, however I am having an issue getting data from my form.

My form is as below within my template -

    <div>
      <CRow>
        <FormulateForm class="fit-form" v-model="formValues"  @submit="addMapping()">
          <CRow>
            <CCol>
              <FormulateInput
                type="select"
                name="code"
                label="Choose Code"
                :options="[{ value: 'id', label: 'B' },{ value: 'id', label: 'S' }]" 
              />
            </CCol>
            <CCol>
              <FormulateInput
                type="text"
                name="mapped"
                label="Type Map Name"
              />
            </CCol>
          </CRow>
          <FormulateInput type="submit" class="queue-btn" />
        </FormulateForm>
      </CRow>
    </div>

This is my data and logic -

export default {
  name: "TxnMappings",
  data() {
    return {
      formValues: {},
      newMapping: {},
      txnData: this.data,//This comes from parent
    };
  },
  props: ["data", "hasAddTxn", "isCreate"],
  methods: {
    addMapping() {
      console.log(Object.entries(this.formValues));
      console.log(JSON.stringify(this.formValues));
    }
  }
};

For a response of ~


"foo":{"bar":{"id":"B","description":"BSK"},"doe":{"id":"D","description":"DOE"}}

~ bar and doe are the user text inputs, B and D are hardcode-able values and BSK and DOE are also hardcode-able. I do not want to post the data from here, I simply cannot get the appropriate output format in JSON with all of the data I need. Any guidance appreciated.

Any further info needed please ask.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This syntax allowed me to set the approperiate values in the right place.

addMapping() {
  this.txnData[this.formValues.mapping] = this.formValues.id 
  console.log(JSON.stringify(this.txnData)) this.formValues = {} 
  //this.$formulate.resetValidation('txnXrefs') this section doesn't reset validation, ignore for answer
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!