Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

POST request from form submission missing certain input types #199

Closed
SpencerWoo opened this issue Feb 28, 2017 · 18 comments
Closed

POST request from form submission missing certain input types #199

SpencerWoo opened this issue Feb 28, 2017 · 18 comments

Comments

@SpencerWoo
Copy link
Member

SpencerWoo commented Feb 28, 2017

Expected behaviour

There are various types, but specifically input type="submit" should pass its name/values when it is triggering the post action as per https://www.w3.org/TR/html401/interact/forms.html#successful-controls.

Actual behaviour

When submitting the form with the input type="submit", the request does not have the input's values.

Steps to reproduce

We'll modify an existing working example to reproduce issue.

  1. Go to examples/forms/index.html
  2. In the first form (action="/post") add inputs of various types. One of them being submit (input type="submit" name="s" value="s").
  3. Visit the webpage and submit the form via our input type="submit" (clicking the s button).
  4. Verify no "s":"s" in result on page. Verify input type="text" / "hidden" / etc sends properly.
  5. Additionally look at the POST request sent via developer tools to verify.

Browsers affected

I tested on Chrome, but I don't think its browser or multipart/form-data specific.

@fernandosouza
Copy link
Contributor

fernandosouza commented Mar 2, 2017

Hey, @SpencerWoo. Thx for reporting. We are going to take a look it. 😃

@brunobasto
Copy link

brunobasto commented Mar 2, 2017

Hey @SpencerWoo, we are using HTML5 FormData to create the body of the request. I haven't tested it yet, but what you describe suggests Chrome doesn't put the value of a submit button into the FormData. Gladly, the API allows us to add more values by calling FormData.append().

Thx for reporting this.

@brunobasto
Copy link

@SpencerWoo
Copy link
Member Author

Thanks all for looking at this. As a note, I believe with a standard form (or when the form has "data-senna-off") the post request does contain the clicked submit button values.

Thanks again for all the responses!

@SpencerWoo
Copy link
Member Author

Hi all,

Any updates on this issue?

@brunobasto
Copy link

brunobasto commented Mar 8, 2017

Hey @SpencerWoo, I'll tackle this issue next. I'll let you know how it goes. Thx

@SpencerWoo
Copy link
Member Author

SpencerWoo commented Mar 8, 2017

Thanks @brunobasto !

edit : oops wrong button -- let me know if you have any questions!

@SpencerWoo SpencerWoo reopened this Mar 8, 2017
@brunobasto
Copy link

@SpencerWoo, here's an initial draft: #202

@brunobasto
Copy link

From the spec, I'm not sure if other kinds of buttons should go into the form data as well. Do you have any pointers on how the spec defines this behavior?

@brunobasto
Copy link

Ok, so I think my PR is not accurate. The spec says:

If a form contains more than one submit button, only the activated submit button is successful.

So, I'll need to update my code.

@SpencerWoo
Copy link
Member Author

Awesome thanks @brunobasto -- yeah as mentioned about the submit button, but from what I can tell everything else works properly (sends data as it does without senna.js). This LPS (https://issues.liferay.com/browse/LPS-69556) mentions button, but I haven't verified.

@brunobasto
Copy link

Another piece of reference here: https://html.spec.whatwg.org/multipage/forms.html#constructing-the-form-data-set

If any of the following conditions are met, then skip these substeps for this element:
...
The field element is disabled.
The field element is a button but it is not submitter.

@brunobasto
Copy link

@SpencerWoo, do you happen to know what would be the expected behavior if an user submits the form using the enter key on a field inside the form? Would the value of the submit button go to the server as well? If there are more than one submit button, which one should go to the server?

@SpencerWoo
Copy link
Member Author

@brunobasto I found this link (http://stackoverflow.com/questions/925334/how-is-the-default-submit-button-on-an-html-form-determined) which is basically saying there's no defined spec for submitting a form with the enter key and the browser chooses which submit button is the default (the triggering one). On chrome it appears to be the first submit button.

brunobasto pushed a commit to brunobasto/senna.js that referenced this issue Mar 10, 2017
@SpencerWoo
Copy link
Member Author

From what I have tested that commit looks good! Currently watching #203.

@jbalsas
Copy link
Contributor

jbalsas commented Mar 13, 2017

Hey @SpencerWoo, @brunobasto, I think this is actually properly explained in the Forms HTML5 Spec, specially in the Implicit submission section.

A form element's default button is the first submit button in tree order whose form owner is that form element.

If the user agent supports letting the user submit a form implicitly (for example, on some platforms hitting the "enter" key while a text field is focused implicitly submits the form), then doing so for a form whose default button has a defined activation behavior must cause the user agent to run synthetic click activation steps on that default button.

@brunobasto
Copy link

Awesome, then my fix proposal already accounts for that.

brunobasto pushed a commit to brunobasto/senna.js that referenced this issue Mar 15, 2017
brunobasto pushed a commit to brunobasto/senna.js that referenced this issue Mar 15, 2017
brunobasto pushed a commit to brunobasto/senna.js that referenced this issue Mar 15, 2017
fernandosouza pushed a commit to fernandosouza/senna.js that referenced this issue May 3, 2017
@mimosu
Copy link

mimosu commented Jul 20, 2018

Nothing### my

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants