#Astro <ClientRouter> & Form Handling
23 messages ยท Page 1 of 1 (latest)
Is this a solid JS component?
You don't need to use a script tag within that
I would instead add your event listeners within the onMount hook that solid JS has
My form tool bar (submit, cancel, delete) etc.. are exactly the same and <ClientRouter/> has a very good user - experience .
What issues did you experience with the ClientRouter and a full solid js component?
I've used that combination a few times now without issue
I did not use solidjs component at all; i am only using "signals" to detect changes in formData; absolutely nothing else ..
Right but you said the reason you weren't doing it was because of the ClientRouter, which leads me to believe you had issues doing it that way ๐
I'm not sure then, I've not tried using solid JS just within a normal Astro components script tag like that ๐
actually every thing works ! also doesn't work ! ๐ ; what happens is as i navigate between different form pages; when i hit sumbit; all the actions from the previous visited form pages are submitted;
that is is the only thing which is actually going wrong ..
And your forms all have unique IDs?
yup and so do the routes; so i explicitly check to ensure that;
Hmmm I would start adding in some console.logs then on submission so you can verify what formdata you are seeing, which might shed some light on things
I did that and i clearly see that the current form Data is getting submitted to the "action" of the current form & surprisingly all the other actions of the other forms.
Does each form have it's own action?
yup unique actions : updateMember; updateTitle,
deleteMember,
deleteTitle,
etc..
if you look below; if you notice ; both the actions are gettign called ! though i hit "submit" on the "updateJobTitle" form ๐
20:36:19 [204] POST /_actions/updateMember/ 18ms
20:36:19 [200] POST /_actions/updateJobTitle/ 12ms
Can I see your submit logic?
Also you can put your code in code blocks by using tripple backticks
like this
and when i hit that submit both these actions get called the "second action" below is from the previously visited page.
20:36:19 [204] POST /_actions/updateMember/ 18ms
20:36:19 [200] POST /_actions/updateJobTitle/ 12ms
Yah I mean I'm only seeing updateJobTitle and deleteJobTitle being used here so I am really unsure why the other actions would be submitting
One thing you could try and do is breakout your actions into separate folders like this so you could have a folder like src/actions/jobTitle.ts which you would use within your actions like
import { jobTitle } from "./jobTitle.ts"
export const server = {
jobTitle,
}
and then you would call it like await actions.jobTitle.update(payload)
I don't know if it will help fix the issue, but maybe can help us narrow down the cause?
also not to derail, but are you using the studiocms UI toasts? ๐ฎ Love those
Good question and I don't know the answer to it haha!
Hopefully someone else from support will pop in today and be able to clarify that