json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

Multiple radio buttons with the same schema value behave incorrectly #887

Closed donalmurtagh closed 7 years ago

donalmurtagh commented 7 years ago

In this plunker demo I've defined a form with a property of type boolean. The property is displayed using a group of radio buttons, the first of which sets the property to true and the other two set it to false.

However, if I change the property to a false value by selecting either option 2 or 3, the button that is shown as selected is always the other false button

Steps to Reproduce

  1. Open the demo
  2. Select Option 1 (true)
  3. Select Option 2 (false)

Option 3 will be shown as selected. Similarly, if you choose Option 3, Option 2 will be shown as selected.

In a regular HTML form, this problem does not occur, i.e. if you have multiple radio button with the same value, the one you click on will be show as selected.

@json-schema-form/angular-schema-form-lead

Anthropic commented 7 years ago

@donalmurtagh Angular doesn't like two radio with the same values.

The following will show the same issue and is pure angular code without our framework:

<input type="radio" name="fred" ng-model="fred" ng-value="true">
<input type="radio" name="fred" ng-model="fred" ng-value="false">
<input type="radio" name="fred" ng-model="fred" ng-value="false">

If you do the same thing in the latest 1.x version it selects both, so I am not sure when they fixed it but you could try ngJS 1.4 or 1.5 and see if that helps.

donalmurtagh commented 7 years ago

I don't agree that selecting both should be considered a fix, but if the behaviour with ASF is the same as in a pure angular form, then I think it's reasonable to close this issue.