ciscoheat / sveltekit-superforms

Making SvelteKit forms a pleasure to use!
https://superforms.rocks
MIT License
2.25k stars 65 forks source link

Conditional fields validation and default values #451

Open TheBous opened 4 months ago

TheBous commented 4 months ago

I'm facing a similar situation (https://github.com/ciscoheat/sveltekit-superforms/issues/282) and I have a dropdown field that controls other inputs type string values that have their own default values, their own validators and constraints. For example: I have a dropdown with 2 values: rectangle, circle. When I enable square value from the dropdown, 2 other inputs type string appears on HTML: width and height. Width with default value of 10 and height with default value of 20, bot with min 5 and max 100. If I choose circle from the dropdown, only 1 input appears on HTML: radius with the default value of 15, min 1 and max 100. How can i solve this ?

TheBous commented 4 months ago

MRE -> https://stackblitz.com/edit/sveltekit-superforms-1-testing-sved9m

ciscoheat commented 3 months ago

Can you please remake the example in Superforms v2 instead of version 1? Here's an updated test project: https://sveltelab.dev/github.com/ciscoheat/superforms-examples/tree/zod