+ Start a Discussion
Gabriella Vasconcellos 9Gabriella Vasconcellos 9 

Checkbox lightning component

Hi Guys!
I want to show on my component a Checkbox Group. The values are already defined by the Record. My code, for now, is this one with all the picklists that work perfectly -
How I can add those 4 checkboxes?


<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
   <lightning:card>
       
           <lightning:layout multipleRows="true">
          <lightning:layoutItem size="6">
       <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="My_Commodity_Interests_include__c" />
       </lightning:layoutItem>
           <lightning:layoutItem size="6">     
               <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="Non_Ferrous_Metals__c"/>
</lightning:layoutItem>
       <lightning:layoutItem size="6">
           <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="Ferrous_Steel__c"/>
               </lightning:layoutItem>
           <lightning:layoutItem size="6">
               <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="Fertilizers__c"/>
               </lightning:layoutItem>
       <lightning:layoutItem size="6">
                          <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="I_am_interested_in_hearing_about__c"/>
</lightning:layoutItem>
       <lightning:layoutItem size="6">
                          <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="Light_Metals__c"/>
               </lightning:layoutItem>
       
                 
               
             
      <aura:attribute name="options" type="List" default="[
    {'label': 'Ross', 'value': 'option1'},
    {'label': 'Rachel', 'value': 'option2'}
    ]"/>
    <aura:attribute name="value" type="List" default="option1"/>

    <lightning:checkboxGroup name="Checkbox Group"
                             label="Checkbox Group"
                             options="{! v.options }"
                             value="{! v.value }"
                             onchange="{! c.handleChange }"/>        
       
            
           </lightning:layout>
  
          
     
   </lightning:card>
    
Harsh P.Harsh P.
Hi,
 
<aura:attribute name="options" type="List" default="[
    {'label': 'Ross', 'value': 'option1'},
    {'label': 'Rachel', 'value': 'option2'}
    ]"/>
    <aura:attribute name="value" type="List" default="option1"/>

    <lightning:checkboxGroup name="Checkbox Group"
                             label="Checkbox Group"
                             options="{! v.options }"
                             value="{! v.value }"
                             onchange="{! c.handleChange }"/>

This line of code showing the 2 values as Ross,Rachel .You want to add this type of other two options or want to add record option Let mw know.