Skip to content

Commit bf5aca5

Browse files
committed
docs: Add docs for reset+submit
1 parent 6403ccb commit bf5aca5

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

docs/toucan-form/changeset-validation/index.md

+23
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,26 @@ const data: MyFormData = {};
5151
<form.Input @label='Last name' @name='lastName' />
5252
</ToucanForm>
5353
```
54+
55+
## Submit and Reset Actions
56+
57+
The component yields back `submit` and `reset` actions for more complex cases of submitting or resetting your form data.
58+
59+
**NOTE:** Calling `submit` directly is **not** required for most cases. The implementation only requires a button tag with the `type="submit"` attribute set.
60+
61+
```hbs
62+
<ToucanForm as |form|>
63+
{{! This should be used for most cases }}
64+
<button type='submit'>Submit</button>
65+
<button {{on 'click' form.reset}} type='button'>Reset</button>
66+
</ToucanForm>
67+
```
68+
69+
However, if you have a more complex case with submission, you can use `form.submit`.
70+
71+
```hbs
72+
<ToucanForm as |form|>
73+
<button {{on 'click' form.submit}} type='button'>Submit</button>
74+
<button {{on 'click' form.reset}} type='button'>Reset</button>
75+
</ToucanForm>
76+
```

docs/toucan-form/native-validation/index.md

+23
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,26 @@ const data: MyFormData = {};
3434
<form.Input @label='Last name' @name='lastName' />
3535
</ToucanForm>
3636
```
37+
38+
## Submit and Reset Actions
39+
40+
The component yields back `submit` and `reset` actions for more complex cases of submitting or resetting your form data.
41+
42+
**NOTE:** Calling `submit` directly is **not** required for most cases. The implementation only requires a button tag with the `type="submit"` attribute set.
43+
44+
```hbs
45+
<ToucanForm as |form|>
46+
{{! This should be used for most cases }}
47+
<button type='submit'>Submit</button>
48+
<button {{on 'click' form.reset}} type='button'>Reset</button>
49+
</ToucanForm>
50+
```
51+
52+
However, if you have a more complex case with submission, you can use `form.submit`.
53+
54+
```hbs
55+
<ToucanForm as |form|>
56+
<button {{on 'click' form.submit}} type='button'>Submit</button>
57+
<button {{on 'click' form.reset}} type='button'>Reset</button>
58+
</ToucanForm>
59+
```

0 commit comments

Comments
 (0)