-
Notifications
You must be signed in to change notification settings - Fork 150
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 component #409
base: main
Are you sure you want to change the base?
Form component #409
Conversation
|
Other points that might warrant discussion around this PR. The answer I'm giving are my own as a starter of conversation and any feedback on them is welcome question: Why using a component and not extending the action api ? import { Form, action } from '@solidjs/router';
const myAction = action(async (data: FormData) => {
console.log("ACTION")
});
const MyForm = () => {
return <Form action={myAction} method="post">
<input name="foo" />
<input name="bar" />
<button type="submit">POST ME</button>
<button name="getsubmit" type="submit" formMethod='get' formAction="newroute" >GET ME</button>
</Form>
}
// vs
const MyForm = () => {
return <form action={myAction} method="post">
<input name="foo" />
<input name="bar" />
<button type="submit">POST ME</button>
<button name="getsubmit" type="submit" formMethod='get' formAction={action("newroute")} >GET ME</button>
</form>
} question: Why the component is inside its own file and not with the other components ? |
Hello, Any advice how to bring this proposition forward ?
|
I admit I missed the point of suggestion. Hard to tell what the value is. There was a discussion about this issue in Discord but I can't seem to find it now. My understanding if I remember was that this would help do client side navigation similar to a Anchor tag by supporting GET method. But then I don't quite understand how actions play into it. Basically is the target the client routed path or the action.. if it is the action then we can support GET encoding without a capital Form Component in the future. If it is the client routed path then actions don't fit exactly. I guess in a sense the client Router views itself as the GET for all routes it defines so only POST would make sense. As I said I might need a much clearer explanation step by step about how this would behave. |
Summary
This PR does 2 things:
Consideration
To achieve this we use the same trick as action which is to globally register the form element in a Set. We register it by ref but we could consider to use solidjs createUniqueId if we prefere to use string instead of dom node.
Example usage
Example app: https://github.com/SarguelUnda/solidrouter-pr-form