0

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.

1

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"
                   />
  • Thanks - just tried that and it didn't help. My problem may relate to other stuff in the component; I've added a PS about one of the bits of other stuff. Good to know the component does basically work. – Keith C Apr 26 '17 at 14:51
  • I tried putting the code inside a lightning:tabset and it still works for me. Like you said it could be something else and maybe a CSS issue. – RedDevil Apr 26 '17 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.