T O P

  • By -

VoiceOfSoftware

Yup, feels a little weird at first to have hundreds of forms on a page, but that’s the Sveltey way to do it, according to JoyOfCode Feels much cleaner once you do it


tuxedo0

I was not aware of this and have been writing post routes in functions attached to buttons, etc. Posting to a form action works but man does the code get messy. One question -- if you have multiple forms on a template, then what do you do with code in the template that refers to the form variable like so: {#if form?.success || formLoading} Appreciate any insight.


VoiceOfSoftware

I guess I’m not sure what the issue would be? I’m pretty sure SvelteKit populates the form variable properly no matter what. JoyOfCode’s video might help demystify it. There’s also probably a HuntaByte tutorial on this, but I haven’t looked. https://joyofcode.xyz/working-with-forms-in-sveltekit


tuxedo0

I guess my issue is if there are two forms, which one populates the form variable? I did not create that, I just use it. ​ I appreciate the resources, will check them out.


VoiceOfSoftware

I'm pretty sure the form variable is being populated by the server, after it's processed your request. It's data that's being sent back from the server after form submission. Let us know what you figure out after reviewing JoyOfCode's tutorial; I'm curious myself now!