-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #267 from haines/handle-non-object-loader-data
Handle non-object loader data in `useDefaultValuesFromLoader`
- Loading branch information
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { json, DataFunctionArgs } from "@remix-run/node"; | ||
import { withZod } from "@remix-validated-form/with-zod"; | ||
import { ValidatedForm } from "remix-validated-form"; | ||
import { zfd } from "zod-form-data"; | ||
import { Input } from "~/components/Input"; | ||
import { SubmitButton } from "~/components/SubmitButton"; | ||
|
||
const validator = withZod( | ||
zfd.formData({ | ||
text1: zfd.text(), | ||
}) | ||
); | ||
|
||
export type LoaderData = string; | ||
|
||
export const loader = (args: DataFunctionArgs) => | ||
json<LoaderData>("Hello, world"); | ||
|
||
export default function FrontendValidation() { | ||
return ( | ||
<> | ||
<ValidatedForm validator={validator} method="post" id="test-form"> | ||
<Input name="text1" type="text" label="Text" /> | ||
<SubmitButton /> | ||
</ValidatedForm> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ae27716
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
remix-validated-form – ./
www.remix-validated-form.io
remix-validated-form.io
remix-validated-form-git-main-aaronp.vercel.app
remix-validated-form-aaronp.vercel.app
remix-validated-form.vercel.app