1

I am creating a Lightning component to update Status__c picklist in my object.

Using the trailhead page I can use lightning:forceData tag to retrieve the record and display them in fields. What I don't know how to do is have it display it in a picklist and display all the available values in there.

  <force:recordData aura:id="recordLoader"
  recordId="{!v.recordId}"
  layoutType="FULL"
  targetRecord="{!v.record}"
  targetFields="{!v.simpleRecord}"
  targetError="{!v.recordError}"
  mode="EDIT"
  />

<div class="Record Details">
    <lightning:card iconName="action:edit" title="Update Library Status">
        <div class="slds-p-horizontal--small">
            <lightning:input label="Library Status" value="{!v.simpleRecord.Status__c}"/>
            <br/>
            <lightning:button label="Save" variant="brand" onclick="{!c.handleSaveRecord}" />
        </div>
    </lightning:card>
</div>

1 Answer 1

2

lightning:input does not support rendering a select list. You can find more on what it supports on its documentation.

If you want to edit a record and to render picklist fields, you may like to use lightning:recordEditForm along with lightning:inputField. A sample component to update picklist field would look like:

<lightning:recordEditForm aura:id="recordViewForm"  recordId="xxxx" objectApiName="API Name of the Object">
    <div class="Record Details">
        <lightning:card iconName="action:edit" title="Update Library Status">
            <div class="slds-p-horizontal--small">
                <lightning:inputField fieldName="Status__c"/>
                <br/>
                <lightning:button label="Save" variant="brand" onclick="{!c.handleSaveRecord}" />
            </div>
        </lightning:card>
    </div>
</lightning:recordEditForm>

You can find more on respective documentation for lightning:recordEditForm and lightning:inputField.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .