File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ export interface FormController {
5959 setFieldError : ( field : string , message : string ) => void ;
6060 setErrors : ( fields : Record < string , string > ) => void ;
6161 setValues : ( fields : Record < string , any > ) => void ;
62+ reset : ( ) => void ;
6263}
6364
6465type SubmissionContext = { evt : SubmitEvent ; form : FormController } ;
Original file line number Diff line number Diff line change @@ -115,6 +115,10 @@ export function useForm(opts?: FormOptions) {
115115 } ) ;
116116 }
117117
118+ const handleReset = ( ) => {
119+ fields . value . forEach ( ( f : any ) => f . reset ( ) ) ;
120+ } ;
121+
118122 // a private ref for all form values
119123 const formValues = reactive < Record < string , any > > ( { } ) ;
120124 const controller : FormController = {
@@ -168,6 +172,7 @@ export function useForm(opts?: FormOptions) {
168172 setValues,
169173 setErrors,
170174 setFieldError,
175+ reset : handleReset ,
171176 } ;
172177
173178 const validate = async ( ) => {
@@ -208,10 +213,6 @@ export function useForm(opts?: FormOptions) {
208213 } , { } ) ;
209214 } ) ;
210215
211- const handleReset = ( ) => {
212- fields . value . forEach ( ( f : any ) => f . reset ( ) ) ;
213- } ;
214-
215216 const activeFormValues = computed ( ( ) => {
216217 return activeFields . value . reduce ( ( formData : Record < string , any > , field ) => {
217218 setInPath ( formData , field . name , unwrap ( field . value ) ) ;
You can’t perform that action at this time.
0 commit comments