Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
File upload field not resetting after a successful submission in VueJS

In my VUeJS application I have a form to submit some data.

Once a user submits the form it should clear the existing field values.

But now when I submit the form it clears the all the fields except the file upload field.

If I uploaded a file called, dummy.pdf, it will display the dummy.pdf even after a successful submission.

Following is my code for the file upload field,

<div class="mb-1">
            <dashboard-input-label
              identifier="document"
              :settings="{ help: true, helpDirection: 'left' }"
            >
              Upload document
              <template slot="helpText">
                Maximum filesize is 5 MB. The default allowed file extensions
                are: pdf, jpeg and png.
              </template>
            </dashboard-input-label>
            <validator-v2
              :identifier="identifier"
              name="document_file"
              :rules="{ required: { message: 'Document is required.' } }"
            >
              <custom-file-upload
                ref="documentDocument"
                v-model="documentFile"
                :max-upload-file-size="5"
                name="document_file"
              ></custom-file-upload>
            </validator-v2>
          </div>

And my form button is,

<disables-submit-on-errors
            :identifier="identifier"
            @proceed="storeDocumentAndAddNew"
          >
            <loading-button ref="submitBtn" size="normal">
              Save & Add new
            </loading-button>

and under the methods, I have

storeDocumentAndAddNew() {
      this.isAddNew = true
      const loader = this.$refs.submitBtn
      this.storeDocument(loader)
    },

reset() {
      this.documentName= null
      this.dateOfIssue= null
      this.expiryDate= null
      this.documentNumber = null
      this.doesNotHaveDocumentNumber = false
      this.doesNotExpire = false
      this.documentFile = null
      this.doesOptIn = false
      this.isAddNew = false
    },

This will clear the name field, and the document number fields, but this won't clear the uploaded document's name...

What change I need to do clear all the fields after a successful submission?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

To support v-model in components the component must implements a value prop and emit the input event.

It sound like the value prop is missing.

It kinda depends on the implementation of your custom-file-upload component, but here an example:

<template>
  <input @input="handleInput" :value="value" />
</template>

<script>
export default {
  prop: ['value'],
  methods: {
    handleInput (e) {
      this.$emit('input', e)
    }
  }
}
</script>
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda