Skip to content

Commit f5afe09

Browse files
Strengthens intro on forms.md, fixes typos and broken links.
1 parent 08122ab commit f5afe09

File tree

6 files changed

+32
-20
lines changed

6 files changed

+32
-20
lines changed

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"tabWidth": 2,
3+
"useTabs": false,
4+
"semi": false,
5+
"singleQuote": true
6+
}

advanced/context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: FormKit provides a reactive context object to expose data to slots,
55

66
# Context object
77

8-
FormKit inputs use a reactive object to expose data to slots, rules, and the underlying [schema](/advanced/schema) that defines the input. This is called the `context` object and is found in the each input's [core `node` object](/advanced/core-node) at `node.context`. The context object has the following properties:
8+
FormKit inputs use a reactive object to expose data to slots, rules, and the underlying [schema](/advanced/schema) that defines the input. This is called the `context` object and is found in the each input's [core `node` object](/advanced/core#node) at `node.context`. The context object has the following properties:
99

1010
<div data-tight>
1111

essentials/forms.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@ description: Collect all of your FormKit data, submit to your server, and handle
55

66
# Forms
77

8-
While you’re free to use `FormKit` inputs by themselves, you’ll usually want to group them into a form. To do this, you simply wrap your inputs in a `<FormKit type="form">`.
8+
While you’re free to use `FormKit` inputs by themselves, you’ll usually want to group them into a form. To do this, simply wrap your inputs in a `<FormKit type="form">`.
99

10-
The `form` type will actively collect all the values from child inputs, using the name of each input as the property name in the resulting data object (just like [groups](/inputs/group)). You can also read and write to form values using v-model just as you would on any input.
10+
The `form` type will actively collect all the values from child inputs, using the `name` of each input as the property name in the resulting data object (just like [groups](/inputs/group)). You can also read and write to form values using v-model just as you would on any input.
1111

12-
A `<FormKit type="form">` tracks the validation state of the form and prevents users from submitting the form if any inputs are invalid. As a convenience, the `form` also outputs a submit button (which you can disable with the `actions="false"` prop).
12+
A `<FormKit type="form">` tracks the form's validation state and prevents users from submitting the form if any inputs are invalid.
13+
14+
### Provided submit button
15+
16+
As a convenience, the `form` outputs a submit button automatically, and provided themes also include a loading spinner. You can alter this button with the `submit-label` and `submit-attrs` props, or disable with `:actions="false"`.
17+
18+
### Full example form
19+
20+
Excluding backend functionality, here is a fully featured form with inputs (`form`, `text`, `email`, `password`), help text, labels, validation with custom messages, and error and submission handling:
1321

1422
<example
1523
name="Register example"
@@ -35,7 +43,7 @@ Using <code>v-model</code> data in your submit handler could lead to unintended
3543

3644
Forms are usually submitted through user actions like clicking a submit button or hitting the `enter` key on a text node within the form. Upon submission, the form (in sequence):
3745

38-
1. It ensures all inputs are settled (finished debouncing).
46+
1. Ensures all inputs are settled (finished debouncing).
3947
1. Emits the `@submit-raw` event.
4048
1. Sets the `submitted` state to true on all inputs — displaying any remaining validation errors (regardless of the `validation-visibility`).
4149
1. If all inputs are valid it fires the `@submit` event.
@@ -46,8 +54,8 @@ Forms are usually submitted through user actions like clicking a submit button o
4654
The most common method of form submission in a modern SPA is an XHR request (think [axios](https://axios-http.com/) or [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)). FormKit is well suited to this task:
4755

4856
- It hands your submit handler a request-ready object.
49-
- If you return a promise from your submit handler it will apply a loading state to your form (`loading` becomes true at `context.state.loading`).
50-
- It handles backend errors by placing error messages directly on the failing inputs **(NOTE: not yet implemented in FormKit Alpha)**.
57+
- If you return a promise from your submit handler, it will apply a loading state to your form (`loading` becomes true at `context.state.loading`). A loading spinner is added in provided themes.
58+
- It handles [backend errors](#error-handling) by placing error messages directly on the failing inputs.
5159

5260
<example
5361
name="Text example"
@@ -182,7 +190,7 @@ When inputs are unmounted from a form — for example when using `v-if` — the
182190

183191
Forms are technically considered `input` types — so they share many of the universal props that standard inputs use.
184192

185-
<reference-table :without="['label', 'help']" :data="[{ prop: 'disabled', type: 'Boolean', default: 'false', description: 'Disables the form submit button and all the inputs in the form.'}, { prop: 'incomplete-message', type: 'String/Boolean', default: '{locale}.ui.incomplete', description: 'The message that is shown to near the submit button when a user attempts to submit a form, but not all inputs are valid.'}, { prop: 'submit-attrs', type: 'Object', default: '{}', description: 'Attributes or props that should be passed to the submit button.'}, { prop: 'submit-label', type: 'String', default: 'Submit', description: 'The label to use on the submit button.'}, { prop: 'actions', type: 'Boolean', default: 'true', description: 'Whether or not to include the actions bar at the bottom of the form (ex. you want to remove the submit button and use your own, set this to <code>false</code>).'}]"></reference-table>
193+
<reference-table :without="['label', 'help']" :data="[{ prop: 'disabled', type: 'Boolean', default: 'false', description: 'Disables the form submit button and all the inputs in the form.'}, { prop: 'incomplete-message', type: 'String/Boolean', default: '{locale}.ui.incomplete', description: 'The message that is shown to near the submit button when a user attempts to submit a form, but not all inputs are valid.'}, { prop: 'submit-attrs', type: 'Object', default: '{}', description: 'Attributes or props that should be passed to the built-in submit button.'}, { prop: 'submit-label', type: 'String', default: 'Submit', description: 'The label to use on the built-in submit button.'}, { prop: 'actions', type: 'Boolean', default: 'true', description: 'Whether or not to include the actions bar at the bottom of the form (ex. you want to remove the submit button and use your own, set this to <code>false</code>).'}]"></reference-table>
186194

187195
## Section keys
188196

essentials/inputs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ For performance, all FormKit inputs support debouncing as a first-class feature.
104104

105105
Internally, FormKit debounces the `input` event. When the debounce has "settled", the new value is “committed” and the rest of the application is then notified via the [input node’s `commit` event](/advanced/core#events). The default debounce delay is 20 milliseconds and can be adjusted with the `delay` prop or config option.
106106

107-
To illustrate this, lets `v-model` a `group` input and observe how its value is not updated until after our egregiously long `delay`:
107+
To illustrate this, let's `v-model` a `group` input and observe how its value is not updated until after our egregiously long `delay`:
108108

109109
<example
110110
name="Delay prop"

essentials/internationalization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@ Writing a locale for your own native language is a great way to contribute to Fo
7979
Of course, you are not required to use our locale builder to submit a language, and are more than welcome to submit a standard pull request with your locale included.
8080

8181
<callout type="info" label="Localization">
82-
If your language is already on the list (lets say English), but your locality speaks a variation of that language (like 🇬🇧 <code>en-GB</code>), please feel free to submit your localized language.
82+
If your language is already on the list (let's say English), but your locality speaks a variation of that language (like 🇬🇧 <code>en-GB</code>), please feel free to submit your localized language.
8383
</callout>

examples/register/register.vue

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<!-- %partial% -->
22
<template>
33
<FormKit
4-
v-model="formData"
54
type="form"
5+
v-model="formData"
66
:form-class="submitted ? 'hide' : 'show'"
77
submit-label="Register"
88
@submit="submitHandler"
99
>
1010
<h1>Register!</h1>
1111
<p>
12-
You can put any type of element inside a form, not just FormKit inputs (although
13-
only FormKit inputs are included with the submission).
12+
You can put any type of element inside a form, not just FormKit inputs
13+
(although only FormKit inputs are included with the submission).
1414
</p>
15-
<hr>
15+
<hr />
1616
<FormKit
1717
type="text"
1818
name="name"
@@ -36,7 +36,7 @@
3636
label="Password"
3737
validation="required|length:6|matches:/[^a-zA-Z]/"
3838
:validation-messages="{
39-
matches: 'Please include at least one symbol'
39+
matches: 'Please include at least one symbol',
4040
}"
4141
placeholder="Your password"
4242
help="Choose an account password"
@@ -51,9 +51,7 @@
5151
/>
5252
</div>
5353
</FormKit>
54-
<div
55-
v-if="submitted"
56-
>
54+
<div v-if="submitted">
5755
<h2>Submission successful!</h2>
5856
</div>
5957
<pre wrap>{{ formData }}</pre>
@@ -71,7 +69,7 @@ const submitHandler = async () => {
7169

7270
<style>
7371
p {
74-
font-size: .9em;
72+
font-size: 0.9em;
7573
color: #646464;
7674
line-height: 1.5;
7775
}
@@ -105,7 +103,7 @@ hr {
105103
}
106104

107105
.double > .formkit-outer {
108-
width: calc(50% - .5em);
106+
width: calc(50% - 0.5em);
109107
}
110108
}
111109
</style>

0 commit comments

Comments
 (0)