+ Start a Discussion
Luciano RobertoLuciano Roberto 

Add new item on picklist component Lightning

Folks,
I have a component that has a picklist that is populated through a query in Metadata.
I need to add one more line in the picklist.
Example:
PicklistName:  A
                        B
                        C
These values are automatically filled in by the controller.
I need to include the list value: "--- Select -"

Would stay

PicklistName: - Select -
                        A
                        B
                        C

Thanks
Best Answer chosen by Luciano Roberto
Luciano RobertoLuciano Roberto
Thanks 
Sandhya,
But I managed to solve it, in fact I just needed to include the tag:
<ui:inputSelectOption text="" label="-- Selecione --" />


The code looks like this, If someone needs to:

 <!--Controller Field - Motivo 1-->
    <lightning:layoutItem size="12" padding="around-small">   
        <lightning:select aura:id="Motivo1__c"
                          value="{!v.caseObj.Motivo1__c}"
                          name="motivo1"
                          label="Motivo 1"
                          onchange="{!c.onControllerFieldChange}">
         
               <ui:inputSelectOption text="" label="-- Select --" />
          
            <aura:iteration items="{!v.listMotivos1}" var="val">
               
                <option value="{!val.MasterLabel}">{!val.DependentFieldTextPtBR__c}</option>
            </aura:iteration>
           
        </lightning:select>
    </lightning:layoutItem>

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi,

Check below link where you have some work around.

https://salesforce.stackexchange.com/questions/220088/how-to-populate-lightningselect-with-picklist-field-values
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
 
 
Luciano RobertoLuciano Roberto
Thanks 
Sandhya,
But I managed to solve it, in fact I just needed to include the tag:
<ui:inputSelectOption text="" label="-- Selecione --" />


The code looks like this, If someone needs to:

 <!--Controller Field - Motivo 1-->
    <lightning:layoutItem size="12" padding="around-small">   
        <lightning:select aura:id="Motivo1__c"
                          value="{!v.caseObj.Motivo1__c}"
                          name="motivo1"
                          label="Motivo 1"
                          onchange="{!c.onControllerFieldChange}">
         
               <ui:inputSelectOption text="" label="-- Select --" />
          
            <aura:iteration items="{!v.listMotivos1}" var="val">
               
                <option value="{!val.MasterLabel}">{!val.DependentFieldTextPtBR__c}</option>
            </aura:iteration>
           
        </lightning:select>
    </lightning:layoutItem>
This was selected as the best answer