Closed marbetschar closed 7 years ago
Hi @marbetschar,
Looks like the ui-choicefield-group expects a string value for the ng-model binding. When setting the value to doccacc: "false" the correct option is selected on init:
$scope.form = {
doccacc: 'false'
};
I´m not sure if this is the expected behavior or a bug and I haven´t looked deeper into creating a fix but from having a quick look at the current source I do believe it could support Boolean values with a few small changes to the setViewValue and getViewValue functions.
Not sure it's a bug, but if that is the case @ericivarsson then we should check if the value passed in is a valid boolean value and respect it, not requiring a text value. IMHO it should expect a boolean, not a string. Need to investigate further...
The docs at https://docs.angularjs.org/api/ng/input/input%5Bradio%5D states that value
only supports string values and that you should use ng-value instead for non-string values like boolean in this case.
I´ve verified that this component works as expected when using ng-value for the uif-choicefield-option elements.
What do you think @andrewconnell, not a bug then right? Perhaps update the demo-page with this information?
@marbetschar using ng-value like this should solve your problem: `
Agreed... good catch @ericivarsson
@ericivarsson this indeed solved my problem! Thank you both very much for this hint!! Updating the demo page would be fantastic!
I've added a
uif-choicefield-group
with multipleuif-choicefield-option
's on my page as follows:and this is how the corresponding controller looks like:
Expected Behavior
After page load, the corresponding
uif-choicefield-option
should be preselected:Actual Behavior
None of the
uif-choicefield-option
's are selected: