You need to sign in to do that
Don't have an account?
Shivendra Singh Pawar
How to call a picklist into lightning component ?
Hi
Greetings of the day!!!
I create a country picklist into contact object in Sales app and i want to use it into lightning component to select a country from the <select> in the form,
I am not getting, how I can call a picklist into a lightning component from.
<lightning:select aura:id="NewCon" label="Course" name="NewCon" type="String" value="{!v.NewCon.CourseCategory__c}" required="true"/>
There are 2 ways to do it.
1. Do it using lightning:select where you describe set of options. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_select.htm 2. A better option will be to use <force:inputField> It will automatically determine the type and show checkbox, picklist or text field.
Thank You
www.nubeselite.com
Developement | Training | Consulting
Please Mark this assolution if your problem resolved.
All Answers
Try this:
Still, I am facing a same issue, picklist is not getting populated in form using lightning component and also getting an error
Also, i did not see any attribute defined for a Contact. First create a Contact instance by using above attribute in your component.
After that, refer the picklist field in "force:inputField" as below:
Hope, "CourseCategory__c" is the API name for picklist. If not, use tha correct API name.
We already defined the attribute in this way :
<aura:attribute name="NewCon"
type="Contact"
default="{ 'sobjectType': 'Contact',
'FirstName':'',
'LastName': '',
'Email': '',
'Phone': '',
'CourseCategory__c': ''}"/>
Kindly let me know how the picklist gets populated. I am defining my controls in this way all the controls working fine
<lightning:input aura:id="NewCon" label="First Name" name="NewCon" value="{!v.NewCon.FirstName}" required="true"/>
Plz, let me know how can I use the picklist to select a country.
Plz, suggest some answers asap.
Thanks & Regards
Shivendra
I am not sure that why force:inputField is not working for you.
You can also try below steps:
1) Create a server-side method that returns list of all picklist values available.
2) Call this method when lightning component is initialized (i.e. init method)
3) Iterate through list of picklist options using <aura:iteration> inside <lightning:select> and add each of them as <option>.
There are 2 ways to do it.
1. Do it using lightning:select where you describe set of options. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_select.htm 2. A better option will be to use <force:inputField> It will automatically determine the type and show checkbox, picklist or text field.
Thank You
www.nubeselite.com
Developement | Training | Consulting
Please Mark this assolution if your problem resolved.