-
Notifications
You must be signed in to change notification settings - Fork 22.9k
Enhance HTMLFormControlsCollection description #40841
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
Conversation
Added details about the elements included in the HTMLFormControlsCollection.
Preview URLs (comment last updated: 2025-09-10 08:25:44) |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@@ -9,6 +9,8 @@ browser-compat: api.HTMLFormControlsCollection | |||
|
|||
The **`HTMLFormControlsCollection`** interface represents a _collection_ of HTML _form control elements_, returned by the {{domxref("HTMLFormElement")}} interface's {{domxref("HTMLFormElement.elements", "elements")}} property. | |||
|
|||
The collection of form control elements includes {{htmlelement("button")}}, {{htmlelement("fieldset")}}, {{htmlelement("input")}}, {{htmlelement("object")}}, {{htmlelement("output")}}, {{htmlelement("select")}}, and {{htmlelement("textarea")}} elements whose form owner is the {{htmlelement("form")}} element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I think this should be documented in elements
(which we already do). HTMLFormControlsCollection
is just a collection, and what's put inside this collection is up to each property that returns it, of which there happens to be only one, but this still feels out of place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are form controls that are not sent to the server that are included, so the list is an odd one, which is why i included it. It should be included on this page b/c of that, but perhaps in a different way. Do you have a suggestion?
For example,
- fieldset is not sent to the server, but is in the collection.
- If a control is nested in a form, but has a
form
attribute that dissociates it from its ancestor form, it is not included. - If a fieldset is not in the form, but has a
form
attribute that associates it, it is included, but not sent. It's descendant form controls are only included and sent if they too have theform
attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Josh-Cena I am not saying my solution is the right one, but i do think we should inform the reader that the result may not be obvious. Suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The collection of form control elements includes {{htmlelement("button")}}, {{htmlelement("fieldset")}}, {{htmlelement("input")}}, {{htmlelement("object")}}, {{htmlelement("output")}}, {{htmlelement("select")}}, and {{htmlelement("textarea")}} elements whose form owner is the {{htmlelement("form")}} element. | |
The collection returned by {{domxref("HTMLFormElement.elements")}} includes {{htmlelement("button")}}, {{htmlelement("fieldset")}}, {{htmlelement("input")}}, {{htmlelement("object")}}, {{htmlelement("output")}}, {{htmlelement("select")}}, and {{htmlelement("textarea")}} elements whose form owner is the {{htmlelement("form")}} element. This collection is unrelated to what would be sent when the form is submitted. |
If the intention is to document the dissociation between what's included and what's submitted, then sure we could keep this paragraph, but make that purpose more salient. Also: (1) we should add this caveat to HTMLFormElement.elements
as well, because that's the actually relevant documentation page. (2) the HTMLFormElement.elements
page talks about <input type="image">
not being included, and form-associated custom elements being included, which should be mentioned here as well. Alternatively we could just replace this list with a link saying "See HTMLFormElement.elements
for the list of elements included", which I prefer because it makes it clear that this collection itself doesn't control what can be inside it.
replaced with #41096 |
Added details about the elements included in the HTMLFormControlsCollection.
related to #40760