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

93
Views
Problems sending only the value of a select using typescript

I'm having a problem sending the value of a select to my database. I'm using Vue, quasar and typescript.

I have a modal with name and age inputs, in addition I have a select that selects a category. But, when sending this select value to the database, an object is sent with the label and value of the select. But the database would only accept it if it was a numeric value.

const baseFieldStates = {
  name: '',
  age: '',
  category:  null,
};
//@ts-ignore
const fieldStates: Ref<UserFormData> = ref({
  ...baseFieldStates,
  ...props.userData
});

Here would be my function to save a user and send their data.

const userAction = props.userData ? editUser : createUser
const saveUser = () => {
  userAction(fieldStates.value)
    .then(() => {
      onDialogOK(fieldStates.value);
    })
    .catch(() => {
      onDialogCancel();
    })
};

My select:

          <q-select
            outlined
            class="q-mb-lg"
            :options="rolesOptions"
            option-value="value"
            option-label="label"                
            :label="$t('Users.form.role')"
            v-model="fieldStates.category"
          />

This is an example of how my select is sent to the database.

{label: 'Example', value: 1}

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

0

You need to add emit-value and map-options, see: https://quasar.dev/vue-components/select#affecting-model as described here.

Quasar framework q-select sets an object in the v-model than the id

<q-select
outlined
class="q-mb-lg"
:options="rolesOptions"
emit-value
map-options
:label="$t('Users.form.role')"
v-model="fieldStates.category"
/>
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!