0
I am having a very great frustration in creating new forms within my team’s project. We handle patient information, which means a lot of information. When we create the components of Forms for each view of Insert/Edit, we end up defining a formValues
within the data
to store all fields that will be used as v-model
. The problem is, by doing this, we end up having a very extensive code, as the example below:
export default {
// ...
data: () => ({
formValues: {
nome: null,
nomeMae: null,
telefone: null,
celular: null,
convenios: [],
// Mais propriedades...
}
}),
methods: {
savePaciente() {
const payload = cloneDeep(this.formValues);
// Código de processo
}
},
}
This example seems small, however, when the component grows, when business rules enter, when other negotiations appear, this file becomes more and more extensive, because it deals with so many fields. I wonder if there is any way to refactor these Forms, make them smaller and less verbose.
How does the HTML code look? Does it also look verbose there? I usually have a separate file that has a field manifest, an object that describes fields with label, initial value, etc... Forms are "verbose"...
– Sergio
@Sergio Sim, normally the template ends up becoming very extensive, because it has several components of inputs for each of those fields of formValues
– Gabriel de Oliveira
Can you add an example of a full form? curious how you have the code in the template
– Sergio