12

If you make a small change to your controller's getter method so that the Label value of the option element includes the region in each label, you can then use javascript to build the <optgroup /> elements for you in the page: public List<SelectOption> getCountryName(){ List<SelectOption> options = new List<SelectOption>(); ...


10

You need to set the value that the select list is bound to.. public class mytest{ public string selectedValue {get;set;} public class mytest(){ selectedValue = 'Sister'; } public SelectOption[] getselectValues(){ return New SelectOption[]{ New SelectOption('Mother','Mother'), New SelectOption('Sister','...


9

While creating the SelectOption for the apex:selectRadio you can pass the HelpText as HTML string as title in the label parameter with this constructor SelectOption(value, label) of SelectOption Apex class. Don't forget to use setEscapeItem(false) for the SelectOptions. VF Page <apex:page controller="ViewSurController" lightningStylesheets="true"> ...


8

Schema.DescribeFieldResult has two instance methods that would accomplish what you're asking-- getName() or getLabel() -- which return the field's API name and label, respectively. for(String key:keys) { Schema.DescribeFieldResult d = fieldMap.get(key).getDescribe(); if(d.isAccessible() && d.isUpdateable() && (d.getName() == ...


8

I assume this is for some historical reason as it would be convenient if it did work. Instead you can create your own simple Apex class and convert to that: public class SerializableSelectOption { public String value {get; set;} public String label {get; set;} public SerializableSelectOption(SelectOption so) { this.value = so.getValue(...


7

You can accomplish this by adding an ActionSupport to each of the SelectOptions <apex:pageBlockSection > <apex:actionRegion > <apex:selectList value="{!conid}" size="1" > <apex:selectOptions value="{!Cons}" /> <apex:actionSupport action="{!updateCONLIST}" event="onchange" reRender="pBlock" /> </apex:...


7

What I have done in this scenario in teh past is I create field sets that I know I want to use in certain controllers and classes. Then within your method you can just go through all of the fields in your field set and add the selectoption. This way, should you need new fields as an option, you don't have to adjust your code, you can just update the field ...


7

I usually just do this. Class: public List <SelectOption> getisNDA() { List<SelectOption> options3 = new List<SelectOption>{ new SelectOption('','-Select-') }; List <String> tempList = new List <String> (); tempList.add('Yes'); tempList.add('No'); for (String s: tempList) ...


5

I noticed that you can wrap the first instance of the expression in standard HTML tags but you can't apply any inline css nor add any other properties. So I've come up with something like this: <apex:selectOption itemValue="" itemLabel="<h3>{!$Label.RestrictionTypeAttributeLabel1}</h3><br/><div style='font-size: 14px; padding-left: ...


5

Use layout="pageDirection" in selectCheckboxes for ex. <apex:form > <apex:pageBlock > <apex:pageBlockSection columns="2"> <tr> <apex:selectCheckboxes borderVisible="true" value="{!countries}" styleClass="check" layout="pageDirection"> <apex:selectOptions value="{!items}" /> </...


5

There is something... I found this post Lightning - How to use force:inputField? and I'm validating this markup <force:inputField value="{!v.YourAttributeNameForTheSObject.YourFieldname}" /> It's in the documentation https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_force_inputField.htm The description is ...


5

Place <apex:inputText> in separate outputPanel and try to rerender that panel on actionSupport call. Also added at <apex:ouputText> to confirm the value is correctly be displayed <apex:page controller="ExcelPageController"> <apex:form > <apex:outputPanel id="vendor2"> <p><b>Vendor:</b></p> ...


5

The easiest way, if it works for your use case is to bind directly to this field and let the VF tag build the select list for you. <apex:inputField value="{!Student__c.YourFieldName__c}" /> If you need to build it manually you can create a method in a custom controller extension class which returns options and then bind to it for the options list - ...


5

Whenever you use for:each you have to use key attribute in the child markup. If not it gives a compilation error. From SF Docs: Note that you must use a key to assign a unique value to each item in the list. <select class="slds-select" id="select-01"> <template for:each = {listViews} for:item="listViewItem"> ...


4

The default behaviour when returning a SelectOption from a Remote Action is to return a String with the value in it. If you need to return the label as well then you need to create a wrapper class with exposes the label and return that instead. You'll then be able to access the label property in the JSON object that is returned. public class ...


4

You have to use labels or translation workbench. There are some options to display translated picklists on the visualforce. A salesforce standard way to is to use apex:inputField tag with assigned sobject field of type picklist. In this case a picklist will be generated automatically with respect to the current user language. All you need to do is ...


4

Yes, set the default value on matchAccountId. The Select List should initialize with that value as selected.


4

Here is the error: valuesList = split.fSPE('(,)',0); If you comment this out, the Entity is not API Accessible error goes away (other compiler errors are exposed). You probably wanted valuesList = fSPE.split('(,)',0); For some reason to the compiler, Split is an SFDC entity although I don't see it in the Object Reference Guide (nor is it an Apex ...


4

Issue is with this line: standardSetCntrl = new ApexPages.StandardSetController(Database.getQueryLocator('SELECT Name FROM '+ strSelectedObject +' LIMIT 1')); This variable strSelectedObject would be bound by Visualforce page. You should escape it as: String.escapeSingleQuotes(strSelectedObject); Look like: ApexPages.StandardSetController(Database....


4

The clue to your problem is in the error message: Id none must be 15 characters so it looks like the error occurs when the first entry: options.add(new SelectOption('None','----Select----')); is chosen. For the other entries as kurunve suggests you should use new SelectOption(p.id,Address). The test below shows that a good way to go is to use an empty ...


4

"Overriding" is the process of replacing one method with another in child classes. What you've actually done is something called "shadowing," which is where you've hidden a system class with a custom class. The order of preferences is kind of explained in Type Resolution and System Namespace for Types: For a type reference TypeN, the ...


4

apex:selectOptions is for adding a list of SelectOption objects from Apex. If you want to define the options in visualforce, use apex:selectOption: <apex:pageBlockTable value="{!RowList}" var="c"> <apex:column > <apex:facet name="header">All Surveys</apex:facet> <span>All Surveys: </span> <...


3

The reason you are getting only 0-15 is you used break in your for loop which will terminate the loop after executing it for first time. You cannot get this to be done without using Wrapper class. Controller: public class Wrapper { public ProntoEvents_Product__c prod {get; set;} public List<SelectOption> quantityoption {get; set;} } public ...


3

I'm not sure what you're trying to do here: //Create options. for (Integer i : pricebook2.name) { options.add(new SelectOption(pricebook2.name, pricebook2.name)); } What exactly is 'pricebook2'? If it's a single pricebook, then you don't need a loop - just one new SelectOption. If it's a list of pricebooks, then you need to iterate through the ...


3

Your problem is that you keep adding to the list1 List every time the VF page calls getoptionlist. If you change your logic so that you only initialize list1 once then it will solve your problem. public list<selectoption> list1; ... public List<SelectOption> getoptionlist() { if (list1 == null) { list1 = new list<selectoption>(...


3

Use <apex:selectlist> and <apex:selectOption> Use selected/disabled attribute of <apex:selectOption> <apex:selectlist value="{!city}" size="1"> <apex:selectOption itemlabel="City" itemValue=""/> <apex:selectOption itemlabel="City A" itemValue="City A"/> <apex:selectOption itemlabel="City B" ...


3

You need a value binding: <apex:selectList value="{!selectedClient}"> <apex:selectOptions value="{!clientOptions}" /> </apex:selectList>


3

I am not sure what is inside your interviewSkillReviews in your controller class. But in order to achieve your result, you will need something like this. In your apex controller: List<skillHelper> interviewSkillReviews = new List<skillHelper>(); interviewSkillReviews.add(new skillHelper('ABC')); interviewSkillReviews.add(new skillHelper('Hello')...


3

Before starting your for loop add following line of code. options3.add(new SelectOption(' ', ' '));


3

You can try out something like this: Visualforce <apex:selectList label = "Fields" value="{!selectedFields}" multiselect="false" size="10"> <apex:selectOptions value="{!fieldOptions}" id="field"/> <apex:actionSupport event="onchange" reRender="values" action="{!passValueToController}"/> </apex:selectList> <apex:outputText value=...


Only top voted, non community-wiki answers of a minimum length are eligible