0

This is taking way longer than it should. I have the following . . .

                <apex:pageBlockSection>
                <apex:selectRadio label="Update Existing Contact" value="{!createOrUpdateSite}">

                        <apex:selectOption itemValue="Update Existing Contact" ></apex:selectOption>

                        <apex:selectOption itemValue="Create New Contact (Replace)"></apex:selectOption>



                </apex:selectRadio>
                <apex:actionSupport event="onchange" 
                                    action="{!checkSelectedValue}" 
                                    reRender="none" />

            </apex:pageBlockSection>

And one option should set the 'createOrUpdateSite' string in the controller to 'Update Existing Contact' and the other with the corresponding setting.

That works, as tested with a debug, all is well; the only problem is that I cannot properly label these two options. It is mandatory that these two options are part of the same section because they need to act as a radio option; ie: mutually exclusive. This is by far the least-impressively documented parts of VF I've encountered thus far haha. So guidance would be much appreciated. Thank you.

4

Use the itemLabel attribute on apex:selectOption:

<apex:selectRadio label="Update Existing Contact" value="{!createOrUpdateSite}">
  <apex:selectOption
    itemValue="Update Existing Contact"
    itemLabel="Update Existing Contact"
  />
  <apex:selectOption
    itemValue="Create New Contact (Replace)"
    itemLabel="Create New Contact (Replace)"
  />
</apex:selectRadio>
  • Jeez. Thank you so much! Traversed my way around the internet and found all sorts of variations that weren't compatible with my version, apparently. Thanks a million! Any idea how to get it to inherit the formatting that other labels have? For example, a checkbox field's label as well as this one's label (on the apex:selectRadio) have a certain color and font-weight....whereas the itemLabel is pretty plain... – Natalie Spatharakis Aug 3 '16 at 19:00
  • I don't know of a way to get it to look exactly like the other labels. Using <apex:selectOption> should give it Salesforce's native styles. You can always use the styleClass attribute to apply your own CSS, e.g. <apex:selectOption styleClass="myCustomStyle" /> and then put something like .myCustomStyle { font-weight: bold } inline in your page or in a Static Resource. – Ben Aug 19 '16 at 12:29

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.