Formkit in Vue 3 - how to submit also empty fields

182 Views Asked by At

in Vue 3 I show a form loading its schema.

In that form I have for example a text input that can also be empty. Actually if I leave that field empty, on submitting the form, that fields is not submitted.

here some parts of the Vue code

<div class="row">
    <FormKit type="form" @submit="inviaForm" submit-label="Invia modulo">
        <FormKitSchema :schema="schema" />
    </FormKit>
</div>

...
...
...
...
const schema = JSON.parse(props.form.json_schema)
    
const inviaForm = async (fields) => {
    await new Promise((r) => setTimeout(r, 1000))
    alert(JSON.stringify(fields))
    console.log(fields)

    if(props.course.price == 0) {
        // go
        router.post('/app/'+props.customer.cid+'/subscribe', { 
            submission : fields, 
            course : props.course.id,
            payment_type: '---',
            cost: 0
        })
    } else {
        // il corso è a pagamento
        
    }
    
}

Is there a way to submit all the fields even if some are empty?

Regards, Matteo

0

There are 0 best solutions below