0

In Visualforce/Standard Salesforce UI, if you have a required dependent picklist with only one value, it will default the field to that value and not allow the user to change the value.

Is there any way to replicate that functionality with lightning:input field? I know that we can get the picklist values in the apex controller but I'm hoping there's some way to get the filtered list based on the controlling field.

1 Answer 1

2
+50

Refer to the sample code extract below from the documentation.

The lightning:inputField of the dependent required picklist field gets defaulted if a single value exist.

This example uses LeadSource as the controlling field and Level__c as the dependent field for a dependent picklist.

<lightning:recordEditForm aura:id="recordViewForm"
                                  recordId="{!v.recordId}"
                                  objectApiName="Contact">
    <lightning:messages />
    <!--Other fields here-->
    <lightning:inputField fieldName="LeadSource" />
    <lightning:inputField fieldName="Level__c" />
    <lightning:button aura:id="submit" type="submit" label="Update record" class="slds-m-top_medium"/>
</lightning:recordEditForm>
2
  • That's not how I'm observing it working in my component
    – brezotom
    Oct 18, 2019 at 14:10
  • check the API version of the component, it has to be API 42.0 or later
    – Shamina
    Oct 18, 2019 at 14:12

You must log in to answer this question.

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