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

[v3 docs] Form nesting forms doesnt work #2889

Open
MickL opened this issue Dec 13, 2024 · 1 comment
Open

[v3 docs] Form nesting forms doesnt work #2889

MickL opened this issue Dec 13, 2024 · 1 comment
Assignees
Labels
bug Something isn't working v3 #1289

Comments

@MickL
Copy link
Contributor

MickL commented Dec 13, 2024

For what version of Nuxt UI are you suggesting this?

v3.x

Description

For Form the example about nesting forms doesnt fully work out:

  1. When activating the checkbox and adding an email, and then deactivating the checkbox, the email stays in the state object.
  2. When submitting with checkbox activated and email inserted, the email is not part of the submit data.
  3. There is a small issue: news is a require boolean, therefor the form never submits when the checkbox has not been touched. Should be: news: z.boolean().default(false)

Btw. I think an example about nesting forms is very important because it is a common tasks to have compose a form out of multiple components. BUT maybe another example could be added because the same can be archived with a single schema and descrimination union:

const baseSchema = z.object({
  name: z.string().min(2),
  news: z.boolean().default(false),
});
const schema = z.discriminatedUnion("news", [
  baseSchema.extend({ news: z.literal(true), email: z.string().email() }),
  baseSchema.extend({ news: z.literal(false) }),
]);

Maybe this would be even a better solution for the checkbox use case. It should fix #1 and #2, but it doesnt work for nested forms this way.

Additional context

No response

@MickL MickL added enhancement New feature or request triage labels Dec 13, 2024
@benjamincanac benjamincanac added the v3 #1289 label Dec 13, 2024 — with Volta.net
@romhml
Copy link
Collaborator

romhml commented Jan 2, 2025

The missing data from the submit payload is a regression introduced with this PR that apply transformations on the state before calling the @submit callback. We're missing a part to get transformations from nested payloads. I'll look into a solution!

@romhml romhml added bug Something isn't working and removed enhancement New feature or request triage labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v3 #1289
Projects
None yet
Development

No branches or pull requests

3 participants