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

Commit f78268f

Browse files
committed
docs(input[radio]): explain what happens with same name on multiple inputs
Closes #15009 Closes #16478
1 parent 85286bd commit f78268f

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

0 commit comments

Comments
 (0)