You need to sign in to do that
Don't have an account?

Checkboxes not saving
Hi,
I have a multiselect (Picklist) field in my object which I try to disply as a list of checkboxes using the following code inside the controller:
public List<SelectOption> Items { get { List<SelectOption> options = new List<SelectOption>(); Schema.DescribeFieldResult fieldResult = MyObj__c.Checklist__c.getDescribe(); List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); for( Schema.PicklistEntry f : ple) { options.add(new SelectOption(f.getLabel(), f.getValue())); } return options; } }
Checklist__c is the aforementioned Picklist. Inside my VF page I have the following:
<apex:selectCheckboxes value="{!MyObj.Checklist__c}"> <apex:selectOptions value="{!Items}"/> </apex:selectCheckboxes >
When I hit save I get an error that says Conversion Error setting value 'Option C Option D' for '#{MyObj.Checklist__c}'. My Picklist currently has the values Option A, B, C and D in it. Any ideas what I'm missing here?
Thanks in advance.
You are trying to set the value of a multi select picklist from an "Array of Strings". Typically "select:checckboxes" expects an Array to set the selections into.
I would change to
<apex:selectCheckboxes value="{!ctlr.userSelections}"> <apex:selectOptions value="{!Items}"/></apex:selectCheckboxes >
where ctlr.userSelections is a List<String> and a controller variable. In the action method that you are calling, make sure you iterate through this list and set the value to the multi-select picklist (I think you need to separate them with a ';' e.g. Option 1;Option 2)
All Answers
You are trying to set the value of a multi select picklist from an "Array of Strings". Typically "select:checckboxes" expects an Array to set the selections into.
I would change to
<apex:selectCheckboxes value="{!ctlr.userSelections}"> <apex:selectOptions value="{!Items}"/></apex:selectCheckboxes >
where ctlr.userSelections is a List<String> and a controller variable. In the action method that you are calling, make sure you iterate through this list and set the value to the multi-select picklist (I think you need to separate them with a ';' e.g. Option 1;Option 2)
Hi, do you have the fixed code?
Because I'm having the same problem and couldn't fix it.
Here is what I have on my page:
<apex:selectCheckboxes value="{!objectTypes}" layout="PageDirection">
<apex:selectOptions value="{!objectTypesOptions}"/>
</apex:selectCheckboxes>
and on my controller objectsTypes is a List<String> and objectTypesOptions is a List<SelectOption>
Don't know what is wrong =S
Thanks,
Orlando