Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form validation errors not visible in DOM #287

Open
Deepakeon opened this issue Apr 5, 2024 · 1 comment
Open

Form validation errors not visible in DOM #287

Deepakeon opened this issue Apr 5, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Deepakeon
Copy link

Deepakeon commented Apr 5, 2024

Describe the bug

const form1validatorObj = z.object({
		field1: z.string().min(100, {message: "form 1 error"})
	})

	const form2validatorObj = z.object({
		field2: z.string().min(100, {message: "form 2 error"})
	})
	const {
		form: form1,
		errors: errors1
	} = createForm({
		extend: reporter({ single: true }),
		validate: (values) => {
			return validateSchema(form1validatorObj)(values);
		}
	});

	const {
		form: form2,
		errors: errors2
	} = createForm({
		extend: reporter({ single: true }),
		validate: (values) => {
			return validateSchema(form2validatorObj)(values);
		}
	});	
	$: console.log($errors1, $errors2)
<form use:form1>
	field 1
	<input type="text" name="field1">
	<div
		id="field1-validation"
		data-felte-reporter-dom-for="field1"
		aria-live="polite"
	/>
	<form use:form2>
		field 2
		<input type="text" name="field1">
		<div
			id="field2-validation"
			data-felte-reporter-dom-for="field2"
			aria-live="polite"
		/>
	</form>
</form>

i am trying to use one form inside of another form but when i have errors in form 2 they are not shown in the dom

Which package/s are you using?

felte (Svelte), @felte/validator-zod, @felte/reporter-dom

Environment

  • OS: Windows 11
  • Browser: Edge
  • Version: @felte/reporter-dom: ^1.1.5 @felte/validator-zod: ^1.0.13 felte: ^1.2.7

Additional context

i have a svelte form, inside of which i am calling another svelte form

@Deepakeon Deepakeon added the bug Something isn't working label Apr 5, 2024
@Deepakeon
Copy link
Author

one workaround for this is to use @felte/reporter-svelte package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants