Form

Form creates a form with method set to POST and a couple of enhancements.


POST by default

Most of the forms we build use POST (over GET), so we made it a default to save a couple of keystrokes every time.

<Form> ... </Form>

Built-in spam prevention

Form contains a hidden input to make it a tiny bit easier to prevent spam. To disable this feature, just set the preventSpam option to false.

<Form> ... </Form>

Parses and sanitizes data for you

If you provide Form with a onSubmit handler, Form will use JavaScript to parse and sanitize data for you — without you having to lift a finger.

<script>
function onSubmit (data) {
// Do something with your data
}
</script>
<Form {onSubmit}> ... </Form>

Receive an array of objects

Form contains a helper that lets you send an array of objects through your forms. This is useful when you need to send multiple items of the same type.

<Form {onSubmit}>
<TextInput name="members[0][name]" label="Member 1 Name" />
<TextInput name="members[1][name]" label="Member 2 Name" />
<TextInput name="members[2][name]" label="Member 3 Name" />
<button type="submit">Submit</button>
</Form>