Is there a simple way to select only one radio button with the <apex:selectRadio> component? I searched for examples and found two posts on this topic that did not resolve the issue I'm having. I might be missing something simple.

  • What do you mean by select only one radio button? RadioButton can select one option only.
    – Lance Shi
    Oct 30, 2016 at 3:12
  • Nope, it is letting me select every radio button, which I agree, radio buttons should only allow one selection, but it doesn't in the above code.
    – Dman100
    Oct 30, 2016 at 3:21

2 Answers 2


The reason you are having this issue is because it is not one Radio button. It is a list of radio buttons. While in each one you can only select one options. For every one you can choose one.

I don't think there is a very quick fix for this one. Either, you give up using apex repeat in this case and put all the opportunity roles in the option list. In that case, you will be able to select only one primary opportunity role. Or otherwise, if you still want the table structure, you will need to use Javascript to enhance the logic.


There's no way to have it work the way you expect; each iteration in your apex:repeat creates a new radio group, which is why you can select all of the radios. They're simply not one logical group. To get a better idea of how apex:selectRadio is supposed to work, check out this trivial page:

      <apex:selectOption itemValue="yes" itemLabel="yes" />
      <apex:selectOption itemValue="no" itemLabel="no" />

Usually, this means people resort to using normal checkboxes, and use some JavaScript to make sure only one is selected.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .