You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 9, 2025. It is now read-only.
<ahref="https://www.buymeacoffee.com/dbssman"target="_blank"><imgsrc="https://cdn.buymeacoffee.com/buttons/default-orange.png"alt="Buy Me A Coffee"height="41"width="174"></a>
15
+
</div>
16
+
17
+
14
18
## 📦 Installation
15
19
---
16
20
``` yarn add vue-form-handler ```
@@ -99,4 +103,4 @@ This project is heavily inspired by other awesome projects like:
The `FormHandler` component is an utility for people that are still using the options API or, that for some reason want to do the handling on the template side.
4
+
5
+
::: tip
6
+
It is highly recommend that you use the `useFormHandler` composable if possible, since it is the intended way of making use of this package and gives you more control over the form.
7
+
:::
8
+
## How it works
9
+
10
+
You pass the same props as you'd be passing to the composable but to a component on the template, and the component will enable you a [scoped slot](https://vuejs.org/guide/components/slots.html#scoped-slots) with the return of `useFormHandler`.
11
+
12
+
As you can imagine, the `FormHandler` composable and `useFormHandler` share the same API but differ in the usage.
Notice how we use the combination of [setError](/api/use-form-handler/set-error) and `clearError` in order to invalidate the form when we have some fields that need to be validated together and the error is not scoped to one single field but to the whole field group.
49
+
50
+
### Clearing the errors of a form after triggering validation/ submitting on demand
| dirty |`Record<string, boolean>`| Object containing all the inputs that have been modified |
10
+
| errors |`Record<string, string>`| Object containing all the current field errors of the form |
11
+
| touched |`Record<string, boolean>`| Object containing all the inputs the users has interacted with |
12
+
| isDirty |`boolean`| True if there is any modified field on the form |
13
+
| isTouched |`boolean`| True if there has been any interaction with a form field |
14
+
| isValid |`boolean`| True if there are no form errors |
15
+
16
+
## Rules
17
+
18
+
`formState` is read-only, so no assignments are expected. It is entirely reactive, so you can react on changes of the whole element and/or it's main attributes.
0 commit comments