function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
fadwa mangougfadwa mangoug 

Displaying a picklist field in lightning component ?

hey everyone, 

I m strating with Lightning components and I need to do something like this : (in Visualforce page)

<apex:inputField label="Client" value="{!Opportunity.client__c}"  style="width:70%;"/> <br/>

With lightning i tried this : 

<ui:inputSelect aura:id="client" label="client"
                                          class="slds-input"
                                          labelClass="slds-form-element__label"
                                          value="{!v.opportunity.client__c}"/>

But the list doesn't display the picklist values when its with lightning components !

Anyone can help please ? 

Thanks !
mkaufmanmkaufman
<ui:inputSelect> is not a Salesforce Picklist field, it is an HTML <select> tag.  You have to provide your own dropdown values using <ui:inputSelectOption> tags.  Theoretically <force:inputField> would do what you want, except there's a known issue with that tag right now that is preventing it from rendering.  That is supposed to be fixed in Winter '17.

The simplest solution is to just hardcode your own <ui:inputSelectOption> values.  If you want a more robust solution, you'll have to leverage an Apex Controller to do a describe and then iterate through the Picklist values in your component.