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

107
Views
Submit not working when there is a q-select

I have added a q-select And I gate my form a submit event. Submit event not working when there is a q-select.But without the q-select it is working.

    <q-form @submit.prevent="addNewRole" class="q-gutter-md">
       <q-input
           v-model="newRoleForm.name"
           type="text"
           autofocus
           label="Role Name"
           color="info"
           required
       />
    
       <q-select
          v-model="newRoleForm.accessLevel"
          :options="accessTypes"
          label="Access Level"
          color="info"
       />
    
      <q-btn
        class="q-mt-lg"
        color="primary"
        icon="add_moderator"
        label="Add Role"
      />

   </q-form>

<script setup>
const addNewRole = () => {
  alert("works");
};
</script>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You should remove the .prevent modifier, set the type of the button to submit, add a rules prop to the q-input and define the binded data:

<template>
 <q-form class="q-gutter-md" @submit="addNewRole">
  <q-input
   v-model="newRoleForm.name"
   type="text"
   autofocus
   label="Role Name"
   color="info"
   :rules="[ruleRequired]"
  />

  <q-select
    v-model="newRoleForm.accessLevel"
    :options="accessTypes"
    label="Access Level"
    color="info"
  />

  <q-btn
    type="submit"
    class="q-mt-lg"
    color="primary"
    icon="add_moderator"
    label="Add Role"
  />
 </q-form>
</template>

<script>
export default
{
  data()
  {
    return {
      newRoleForm:
      {
        name: '',
        accessLevel: null,
      },
    };
  },
  computed:
  {
    accessTypes()
    {
      return [
        {
          value: 'full',
          label: 'Full access',
        },
        {
          value: 'restricted',
          label: 'Restricted access',
        },
      ];
    },
  },
  methods:
  {
    ruleRequired(val)
    {
      return typeof val === 'number' ? true : (Array.isArray(val) ? val.length > 0 : !!val) || 'Required field'; 
    }
  }
}
</script>
about 4 years ago · Juan Pablo Isaza Report

0

Add type submit for the button, also remove prevent from @submit.prevent

 <q-btn
   type="submit"
   class="q-mt-lg"
   color="primary"
   icon="add_moderator"
   label="Add Role"
 />
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!