When a picklist field is rendered via apex:inputfield it automatically displays the picklist entries available for that field in UI.

In my lightning component I tried doing the same with lightning:input but for some reason it just shows a text box without displaying the picklist entries.

Lightning Component Markup

Genre__c is a picklist field.

<aura:component controller="ShowClass" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >

    <aura:attribute name="AAShow" type="Show__c" default="{'sobjectType':'Show__c'}"/>
    <lightning:input label="Name: " name="LIUI_ShowName" value="{!v.AAShow.ShowName__c}" />
    <lightning:input label="Rating: " name="LIUI_ShowRating" value="{!v.AAShow.Rating__c}" />
    <lightning:input label="Genre :" name="LIUI_ShowGenre" value="{!v.AAShow.Genre__c}"/> 
    <lightning:buttonIcon onclick="{!c.fLIUI_Button_Clicked}" iconName="utility:save" variant="bare" size="large" alternativeText="Save" iconClass="dark"/> 

enter image description here

Can someone tell me what I am missing here ?


lightning:input is a generic input, and defaults to a "text" input. If you want to bind to a field in an sObject, use lightning:inputField instead. Otherwise, if you want to roll your own field, use lightning:select (you'll need to retrieve the picklist values from the server).

| improve this answer | |

A lightning:inputField component displays an editable field based on the field type. For example, if fieldName references a date value, then a date field with a date picker is rendered. If fieldName references a picklist, then a dropdown menu displays values based on your record types. This component requires API version 42.0 and later.

use this component with lightning:recordEditForm and pass in a record ID and object API name.

<lightning:inputField fieldName="fieleName__c" />
| improve this answer | |

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.