Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6e55b89

Browse files
committed
docs(input[radio]): explain what happens with same name on multiple inputs
Closes #15009 Closes #16478
1 parent 64c23e4 commit 6e55b89

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/ng/directive/input.js

+27
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,33 @@ var inputType = {
980980
* @description
981981
* HTML radio button.
982982
*
983+
* **Note:**<br>
984+
* All inputs controlled by {@link ngModel ngModel} (including those of type `radio`) will use the
985+
* value of their `name` attribute to determine the property under which their
986+
* {@link ngModel.NgModelController NgModelController} will be published on the parent
987+
* {@link form.FormController FormController}. Thus, if you use the same `name` for multiple
988+
* inputs of a form (e.g. a group of radio inputs), only _one_ `NgModelController` will be
989+
* published on the parent `FormController` under that name. The rest of the controllers will
990+
* continue to work as expected, but you won't be able to access them as properties on the parent
991+
* `FormController`.
992+
*
993+
* <div class="alert alert-info">
994+
* <p>
995+
* In plain HTML forms, the `name` attribute is used to identify groups of radio inputs, so
996+
* that the browser can manage their state (checked/unchecked) based on the state of other
997+
* inputs in the same group.
998+
* </p>
999+
* <p>
1000+
* In AngularJS forms, this is not necessary. The input's state will be updated based on the
1001+
* value of the underlying model data.
1002+
* </p>
1003+
* </div>
1004+
*
1005+
* <div class="alert alert-success">
1006+
* If you omit the `name` attribute on a radio input, `ngModel` will automatically assign it a
1007+
* unique name.
1008+
* </div>
1009+
*
9831010
* @param {string} ngModel Assignable AngularJS expression to data-bind to.
9841011
* @param {string} value The value to which the `ngModel` expression should be set when selected.
9851012
* Note that `value` only supports `string` values, i.e. the scope model needs to be a string,

0 commit comments

Comments
 (0)