Skip to content

Commit

Permalink
Merge pull request #52 from capply/set-did-submit
Browse files Browse the repository at this point in the history
Set did submit
  • Loading branch information
jnicklas authored Dec 2, 2024
2 parents 4ee4c05 + e2fa983 commit 3d79b24
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-pillows-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"signal-form": patch
---

Add set did submit function
3 changes: 3 additions & 0 deletions lib/create-form-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export function createFormContext<S extends AnyObjectSchema>({
setTouched(name) {
touched.value = { ...touched.value, [name]: true };
},
setDidSubmit(value: boolean) {
didSubmit.value = value;
},
setValue(name, value) {
if (data.value[name] !== value) {
data.value = { ...data.value, [name]: value };
Expand Down
1 change: 1 addition & 0 deletions lib/form-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type FormContext<S extends AnyObjectSchema> = FieldsContext & {
validate(): ValidationResult<InferType<S>>;
onSubmit: FormEventHandler<HTMLFormElement>;
setErrors(errors: ValidationError[]): void;
setDidSubmit(value: boolean): void;
formRef: React.RefObject<HTMLFormElement>;
};

Expand Down

0 comments on commit 3d79b24

Please sign in to comment.