[SalesForce] Problem with lightning:input type=”radio” checked attribute

In this lightning:input markup, the initial checked state defined via the checked attribute is ignored leaving both radio buttons unchecked:

<div class="slds-form--stacked">
    <div class="slds-form-element">
        <lightning:input type="radio"
                         label="Default"
                         aura:id="RELATED_OPTIONS"
                         name="RELATED_OPTIONS"
                         value="DEFAULT"
                         checked="true"
                         />
        <lightning:input type="radio"
                         label="Estate Of"
                         aura:id="RELATED_OPTIONS"
                         name="RELATED_OPTIONS"
                         value="ESTATE_OF"
                         checked="false"
                         />
    </div>
</div>

Removing the name="RELATED_OPTIONS" (that ensures only one is checked) avoids the problem but then requires explicit code to uncheck the unselected option.

Is there a cleaner way to make this work?

PS

This is inside a couple of layers of lightning:tabset/lightning:tab that may be having some influence.

Best Answer

I tried the below and it worked for me. it set the first radio to checked correctly.Can you check your console to see if there is any markup error in console?

<lightning:input type="radio"
                     label="Default"
                     aura:id="RELATED_OPTIONS"
                     name="RELATED_OPTIONS"
                     checked="true"
                     />
    <lightning:input type="radio"
                     label="Estate Of"
                     aura:id="RELATED_OPTIONS"
                     name="RELATED_OPTIONS"
                     value="ESTATE_OF"
                   />
Related Topic