Your issue could be related to the problem mentioned here
What I did to get around this was to define all my lists in the Apex controller, like this:
First, make an inner Apex object:
public class SelectItem {
@AuraEnabled
public String label {get; set;}
@AuraEnabled
public String value {get; set;}
@AuraEnabled
public String class {get; set;}
@AuraEnabled
public Boolean selected {get; set;}
}
Using this object, you'd run all the logic you have above in the Apex controller, outputting a list of this custom inner object.
Then, define an attribute of this type in the component:
<aura:attribute name="stageNameValues" type="CustomController.SelectItem[]" />
Then, use an iteration to define the inputselect:
<ui:inputSelect class="slds-select " value="{!v.opportunity.StageName}" updateOn="change" label="Stage" labelClass="slds-form-element__label " requiredIndicatorClass="slds-required" required="true" >
<aura:iteration items="{!v.stageNameValues}" var="source">
<ui:inputSelectOption text="{!source.value}" label="{!source.label}" />
</aura:iteration>
</ui:inputSelect>
Finally, set the attribute when your getter from the Apex class returns:
cmp.set("v.stageNameValues", response.getReturnValue());
This is verified to work. Kind of a pain, I know.
You've forgotten a required attribute. The radioGroup is grounded in HTML's <input type="radio" />
, which uses a "name" attribute to determine groups. If you forget to specify the name, the options actually behave like independent radio groups. The following change is necessary for proper operation:
<lightning:radioGroup name="recordTypes" options="{!v.recordTypes}" value="{!v.recordTypeValue}" required="true" />
Where "name" should be unique to each lightning:radioGroup within the component.
Note: The documentation lists "name" as optional; this is clearly a developer/documentation oversight, because without a name, this component won't work as expected.
Best Answer
You code will be looking like this
For detailed explanation, refer my blog post: Displaying lightning:radioGroup dynamically from SOQL query