Chapter 3 Complete.

This commit is contained in:
Colin Diem
2022-04-21 20:36:02 -04:00
parent bc1cf7b5c3
commit 11919b6b5f
2 changed files with 9 additions and 2 deletions

View File

@@ -3,10 +3,12 @@ import { toast, Toaster } from '@redwoodjs/web/toast'
import {
FieldError,
Form,
FormError,
Label,
TextField,
Submit,
TextAreaField,
TextField,
useForm,
} from '@redwoodjs/forms'
const CREATE_CONTACT = gql`
@@ -18,9 +20,11 @@ const CREATE_CONTACT = gql`
`
const ContactPage = () => {
const formMethods = useForm({ mode: 'onBlur' })
const [create, { loading, error }] = useMutation(CREATE_CONTACT, {
onCompleted: () => {
toast.success('Thank you for your submission!')
formMethods.reset()
},
})
@@ -33,7 +37,8 @@ const ContactPage = () => {
<MetaTags title="Contact" description="Contact page" />
<Toaster />
<Form onSubmit={onSubmit} config={{ mode: 'onBlur' }}>
<Form onSubmit={onSubmit} error={error} formMethods={formMethods}>
<FormError error={error} wrapperClassName="form-error" />
<Label name="name" errorClassName="error">
Name
</Label>