Skip to content

Commit

Permalink
Allow serialization of button name and value
Browse files Browse the repository at this point in the history
  • Loading branch information
danielweinmann committed Feb 20, 2023
1 parent be5a130 commit 17e9a4e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/remix-forms/src/createForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@ function coerceToForm(value: unknown, shape: ShapeInfo) {
return parseDate(value as Date | undefined)
}

if (typeName === 'ZodEnum' || typeName === 'ZodString' || typeName === 'ZodNumber') {
if (
typeName === 'ZodEnum' ||
typeName === 'ZodString' ||
typeName === 'ZodNumber'
) {
return String(value ?? '')
}

return value ?? '';
return value ?? ''
}

function createForm({
Expand Down Expand Up @@ -419,6 +423,7 @@ function createForm({
return React.cloneElement(child, {
disabled,
children: buttonLabel,
onClick: onSubmit,
...child.props,
})
} else {
Expand Down

0 comments on commit 17e9a4e

Please sign in to comment.