-
Notifications
You must be signed in to change notification settings - Fork 434
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
No way to POST form to server #152
Comments
You can use your favorite library for this. Superagent for example: var request = require('superagent');
...
var Login = React.createClass({
...
submit: function (data) {
request.post('/app/login', data).end(function (err, res) {
// do smth
});
},
...
render: function () {
return (
<Formsy.Form onValidSubmit={this.submit}>
... |
I don't want to do client-side requests. I want to use HTTP POST. Method="post" action="mypage.php" Thanks for setting the label. I couldn't do it on my phone. |
I'm sorry, I can't quite understand why not make http post requests from the script. |
Because then I have to handle errors and routing clientside. That would make a huge mess in my code. |
I believe that this feature does not exist, so this is less of a question and more of a request. |
I can't quite tell what you're going for either. Do you want to perform client-side validation and then, if the validations are all good, perform a standard POST? |
Yes. |
You could use any of the validation-related methods described in the API to achieve your goal, depending on the behavior you're looking for. The example in the Readme will, for example, disable the submit button until the form is valid. Upon submitting the form, it will do a standard POST. |
It does not do a standard POST. It triggers a submit method that has some unknown function. There is also no way to set an action or a method AFAIK. |
My apologies. You’re correct and it does expect you to handle POST your own way. Here is the function: https://github.com/christianalfoni/formsy-react/blob/master/src/main.js#L81-L94 https://github.com/christianalfoni/formsy-react/blob/master/src/main.js#L81-L94 I don’t think you can pull of what you want to then. Just might not be the library you’re looking for.
|
Yeah, this is more of a feature request than a question now. |
+1 to this. I'm using formsy mainly to maintain state for a complex form, including custom validations. Works well for that. What I would then like to do is trigger a normal HTTP post by passing the action and method parameter. If this is something that will be considered, I can send a pull request. |
Hi there, Formsy is built for flexibility. There are so many different ways of handling a form and to support most of them Formsy has a lot of hooks. Initially Formsy did support posting data directly to the server and handle any errors, but the implementation was too specific. There were so many requests on support of headers, map errors from server etc. It just got way out of control. So instead of having one very opinionated implementation of talking to the server, it has an extremely flexible hook that lets you do it exactly as you want to. So I am sorry to say that this will not be implemented... and I can not really see that this is a problem?: sendData(form, reset, invalidate) {
myAjaxLib.post('/form', form)
.success(this.doWhatever)
.error(invalidate);
},
render() {
return <Formsy.Form onSubmit={this.sendData}/>
} Sorry to be such a dick about it ;-) |
I also can't believe that Formsy doesn't have this out of the box. Thats literally a book example of what Anyway, I added #441 to add support for standard submit. @christianalfoni: any chances to get this merged? |
It amazes me that there is no built in way to submit the form to the server. I don't want to do $.post. I want an action with a URL and a POST method. I've tried setting those attributes in <Formsy.Form> and programmatically to no avail. None of the examples even show what happens after you click submit. Nobody alerts with a JSON string after submitting a form! Any way to submit a form normally so I can use my server side validation and routing?
The text was updated successfully, but these errors were encountered: