• Dan Olson 15
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I am building a 'List<SelectOption>' and populating it with 'new SelectOption's, then using it in an apex:selectCheckboxes construct to output a set of checkboxes on a VF page. When Salesforce generates the checkboxes, I see the <input> and <label> tags as I expect. However, some of the labels in a list are very long, and I want to disable the functionality of clicking the labels to change the status of the associated checkbox. It can lead to inadvertent setting or unsetting of the checkbox values. How can I disable the clickability? In straight HTML coding, I can set the onclick handler to return false, which prevents it from altering the checkbox value, but I have not been able to figure out how to implement that in this case, since I don't seem to have access to parameters of the <label> command.

Example coding from the controller:
dynamicSEPOptions = new List<SelectOption>();
dynamicSEPOptions.Add(new SelectOption('First', '</label>Short normal label<label>'));
dynamicSEPOptions.Add(new SelectOption('Second', '</label>This is a very long label, which should point out that it could lead to inadvertent setting of the checkbox value<label>'));
dynamicSEPOptions.Add(new SelectOption('Third', '</label>This is an even longer label, wrapping over several lines, which, regardless of the content of the text, should not be clickable to set the checkbox value because it doesn\'t conform to current web experience standards and can result in incorrect checkbox values<label>'));

Example code from the VF page:
<apex:selectCheckboxes value="<field name>" layout="pageDirection" >
     <apex:selectOptions value="{!dynamicSEPOptions}" />
</apex:selectCheckboxes>

Output checkbox list on the page:
Output example of checkboxes
I am building a 'List<SelectOption>' and populating it with 'new SelectOption's, then using it in an apex:selectCheckboxes construct to output a set of checkboxes on a VF page. When Salesforce generates the checkboxes, I see the <input> and <label> tags as I expect. However, some of the labels in a list are very long, and I want to disable the functionality of clicking the labels to change the status of the associated checkbox. It can lead to inadvertent setting or unsetting of the checkbox values. How can I disable the clickability? In straight HTML coding, I can set the onclick handler to return false, which prevents it from altering the checkbox value, but I have not been able to figure out how to implement that in this case, since I don't seem to have access to parameters of the <label> command.

Example coding from the controller:
dynamicSEPOptions = new List<SelectOption>();
dynamicSEPOptions.Add(new SelectOption('First', '</label>Short normal label<label>'));
dynamicSEPOptions.Add(new SelectOption('Second', '</label>This is a very long label, which should point out that it could lead to inadvertent setting of the checkbox value<label>'));
dynamicSEPOptions.Add(new SelectOption('Third', '</label>This is an even longer label, wrapping over several lines, which, regardless of the content of the text, should not be clickable to set the checkbox value because it doesn\'t conform to current web experience standards and can result in incorrect checkbox values<label>'));

Example code from the VF page:
<apex:selectCheckboxes value="<field name>" layout="pageDirection" >
     <apex:selectOptions value="{!dynamicSEPOptions}" />
</apex:selectCheckboxes>

Output checkbox list on the page:
Output example of checkboxes