Tips for developing a dynamic form with Vue.js using Vuetify

I am in the process of creating a dynamic form that needs to function properly. Within my array of competences, there is a skills array. Each skill within a competence needs to be evaluated, requiring a corresponding answer.

My setup involves a v-stepper with dynamic steps, and the form fields are being generated using v-for. Each skill requires a unique v-model to bind the data as competences can have multiple skills.

answers: [
  skillId:
  skillLevel:
  feedback:
  feedforward:
  ...
]

My concern is that with dynamically generated forms, how can I set the v-models for each field, considering a competence can have multiple skills that require individual models?

Below is a snippet of my code

<template>
  <v-stepper v-model="e1" :appraisal="appraisal">
    <v-stepper-header>
      <template v-for="n in steps">
        <v-stepper-step :key="`${n}-step`" :step="n" :complete="e1 > n" editable></v-stepper-step>
        <v-divider v-if="n !== steps" :key="n"></v-divider>
      </template>
    </v-stepper-header>
    <v-stepper-items>
      <v-stepper-content v-for="n in steps" :key="`${n}-content`" :step="n">
        <v-row align="center" justify="center">
          <v-col cols="4">
            <v-subheader class="headline">{{appraisal.appraisalCompetences[n-1].competence.name}}</v-subheader>
          </v-col>
        </v-row>
        ... (truncated for brevity)
      </v-stepper-content>
    </v-stepper-items>
  </v-stepper>
</template>
...

Answer №1

There are efficient Vue.js and Vuetify form generators available that are based on standard JSON Schema. Take a look at the examples and projects below to gain insight and understanding on how to create a robust form generator:

Explore the GitHub repository for more details.

View live examples of the form generator in action.

If you prefer to start a project from scratch, consider a simple concept like rendering an inline edit in a table using references for object passing. Refer to the example below for illustration:

Study the logic carefully, ensure proper indexing in your code. Debugging revealed that referencing answers from 0 to 5 is essential for functionality. Read the following carefully to address any issues:

<v-col cols="2">
    <v-select
        v-model="answers[index + (competence.competenceId-1)*competence.competenceSkills.length ].skillLevel"
        outlined
        :items="selectLevels"
        label="Select"
        item-text="level"
        item-value="value"></v-select>
</v-col>
<v-col cols="2">
    <v-textarea v-model="answers[index + (competence.competenceId-1)*competence.competenceSkills.length].feedBack" outlined rows="3"></v-textarea>
</v-col>
<v-col cols="2">
    <v-textarea v-model="answers[index + (competence.competenceId-1)*competence.competenceSkills.length].selfAppraisal" outlined rows="3"></v-textarea>
</v-col>
<v-col cols="3">
    <v-textarea v-model="answers[index + (competence.competenceId-1)*competence.competenceSkills.length].feedForward" outlined rows="3"></v-textarea>
</v-col>

Alternatively, consider separating answers for a more organized approach:

Review the solutions provided in the following images to understand how to fix any issues and improve the structure of your code:

Image 1

Image 2

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Switching from Webpack-simple to Webpack in a Vue application: A step-by-step guide

I mistakenly created a vue application using webpack-simple, which I now realize is not suitable for deployment. Is there a way to switch to webpack without starting over with a new project? Thank you in advance. Edit: Below is the server.js code where I ...

Encountering a Zone.js error when trying to load an Angular 7 app using ng serve, preventing the application from loading

Scenario: Yesterday, I decided to upgrade my Angular app from version 5.2.9 to 6 and thought it would be a good idea to go all the way to 7 while I was at it. It ended up taking the whole day and required numerous changes to multiple files, mostly due to R ...

Using Javascript to transmit audio via a microphone

I am currently trying to use Selenium to simulate a user on a website that features audio chat. My goal is to emulate the user speaking through the microphone. While I have come across several resources discussing how to listen to the microphone in JavaSc ...

Facebook-Clone Chrome extension that automatically displays "User is listening to..."

I'm currently developing a Chrome Extension that will replace the chat input box with the music I'm listening to by simply pressing "´". It's worth noting that the chat is designed using react and does not use the traditional input/textarea ...

Is there a way to trigger a confirmation function for form submission exclusively when clicking one specific submit button, and not the other?

Here is the layout of my form: <form action="newsletter.php" name="newsletter" id="newsletter" method="post"> <input type="submit" value="Submit" class="c-btn" id="submit_value" name="submit_value"> <input type="submit" value="Send" cla ...

The Context API leaves me feeling lost and confused

I am currently utilizing Auth0 for user sign up. My goal is to extract the user id listed under sub:value, and then add it to my database to associate it with a user's post. To achieve this, I am attempting to utilize a Context API to retrieve the use ...

Challenges of Vue 3 Typescript ComputedRef

I've run into some challenges with Typescript and Vue3. It seems like I might be using Typescript incorrectly in this case. I set up a store using Vue's Composition API. import {computed, reactive} from "vue"; const state = reactive({ ...

Is there a way for me to determine the dimensions of the webcam display?

How do I determine the width and height of the camera in order to utilize it on a canvas while preserving proportions? I am attempting to ascertain the dimensions of the camera so that I can use them on a canvas. On this canvas, I plan to display live vid ...

Use Vue and Axios to dynamically populate a select tag with data from an API

I am looking to populate a select tag with data from an API GET request. Here is the HTML code snippet: <div id="app"> <label for="country" class="control-label">Country</label> <select v-model="selectedCountry" @change="onCha ...

Creating an Image slideShow with only one Image - making it slide on itself

Apologies for this confusing and vague question. Imagine I only have a single image, and I want to create a slideshow using technologies like Angular, jQuery, JavaScript, or just CSS. What I am aiming for is when the user clicks on my slide button, the i ...

What could be causing the issue of this JQuery dropdown plugin not functioning properly on multiple dropdowns?

I have implemented a JQuery plugin for dropdown menus that can be found at the following link: https://code.google.com/p/select-box/ Currently, I am facing an issue where the script only seems to work for the first dropdown menu out of 4. I am unsure abo ...

Issue with integrating external assets in Nuxt framework

I'm currently in the process of integrating a Survey.js survey into a Nuxt project. Following the official documentation, I am adding the necessary external resources. <template> <div class="container"> <div id="sur ...

Apply a CSS class to the initial item in each carousel present on a webpage

I am utilizing Bootstrap 4's carousel to showcase dynamic content. The challenge lies in marking the first item of the carousel with the CSS class ".active". While it is typically added directly in the HTML, it becomes complicated when dealing with dy ...

Retrieve the URI data from the response object using Axios

Currently, I'm in the process of transitioning a node project from utilizing request.js to incorporating axios.js While using the request package, extracting URI data from the response object can be achieved like so: request(req, (err, response) =&g ...

Encountering a socket.io error in vue-cli with an Uncaught TypeError: exists function not found

I have recently integrated socket.io into my vue-cli project using npm and am using it as shown below: import socketio from 'socket.io'; import VueSocketIO from 'vue-socket.io'; export const SocketInstance = socketio(MY_URL); Vue.use( ...

Troubleshooting JavaScript Oscilloscope: resolving audio playback problems

I am exploring JavaScript for the first time and came across an interesting oscilloscope example on this GitHub page. It seemed quite easy to follow initially, but I am facing an issue with audio playback. Although the HTML5 audio element loads the audio f ...

What is the preferred approach: displaying a message using a service or a directive?

I'm feeling a bit unsure. I understand that anything interacting with the DOM should be created as a directive. However, I find it more convenient to simply call my notification service to display error or success messages. This service internally cr ...

Click to slide the div down and up when needed

Currently, I am utilizing the code below to implement a slide up/down effect on a div using JavaScript. The slide down action is triggered by a button, while the slide up action is associated with a close text. My goal is to have the button toggle betwee ...

Is it possible to manually trigger a version change transaction in IndexedDB?

I have been working on a Chrome extension that uses the IndexedDB to store data client-side in an IDBObjectStore within an IDBDatabase. The data structure requires users to be able to modify the object store freely, such as adding new objects or modifying ...

Sending files through ajax with php

Hey there! I've been working on uploading files using Ajax and PHP, following a tutorial. Here's the code I have so far: upload.js: var handleUpload = function (event){ event.preventDefault(); event.stopPropagation(); var fileInput= document.ge ...