I am using composition api and i have used fields as reactive
<Field
type="text"
class="form-control form-control-lg "
name="product_name"
placeholder="Product Name"
v-model="productDetails.product_name">
</Field>
<div class="fv-plugins-message-container">
<div class="fv-help-block">
<ErrorMessage name="product_name"/>
</div>
</div>
Hi,
You can use resetForm
function, and as a parameter provide an object of form initial values.
resetForm({
values: {
//your form initial values
},
});
Hi Lauris ,
the above mentioned solution worked for the normal fields however it did not work for those fields which have v-slot in it ,
<Field name="product_type_id" v-slot="{ field,handleChange }">
<Multiselect v-model="productDetails.product_types.value"
v-bind="productDetails.product_types"
placeholder="Select Product Type"
@change="handleChange"
></Multiselect>
</Field>
<Field
name="product_description"
v-model="productDetails.product_description"
v-slot="{ field,handleChange }"
>
<textarea class="form-control" placeholder="Description" @change="handleChange"></textarea>
</Field>
Hi,
Could you please try to remove v-model directive from your multiselect field?
And you can replace your textarea code with the same Field
component with as="textarea"
prop attribute.
<Field as="textarea" name="description" />
Hi Lauris,
The solution you told me for text-area worked however, even after removing the v-model from the multi-select it did not work,
<Field name="product_type_id" v-slot="{ field,handleChange }">
<Multiselect
v-bind="productDetails.product_types"
placeholder="Select Product Type"
@change="handleChange"
></Multiselect>
</Field>
Hi,
You need to remove handleChange
function and @change
event from your component, and add v-bind and v-model directives as shown below.
<Field name="yourFieldName" :value="defaultValue" v-slot="{ field }">
<Multiselect
v-bind="field"
v-model="field.value"
:options="options"
></Multiselect>
</Field>
It worked , Thanks a lot.
Hi,
Glad to hear that. Please don't hesitate to reach out if you need anything more from us.
Regards,
Lauris Stepanovs,
Keenthemes Support Team