+ Start a Discussion

Using Second Component to Iterate

I am having an issue updating data in a list attribute.  I confirmed that I have two records in the newGroupStructures component.  Please refer to the following main component.  This component gets passed a record from another component and populates the 'existinggroupstructure' attribute with the data from that record. I am trying to use that record as a starting point to allow users to make changes and then create a new record.  The attribute named CloneNumber also gets populated with a value from the component that calls it.  So if the value is two, there are two new records created and populated with the data of the record that was passed.
  Here is the main component...

<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId,lightning:actionOverride" controller="GSClone">
    <!-- here is the variable to hold the group structure that gets passed from the GroupStructures Component (that was clicked) -->
	<aura:attribute name="existinggroupstructure" type="Group_Structure__c[]" />
    <aura:attribute name="CloneNumber" type="Integer"/>
    <aura:attribute name="newGroupStructures" type="Group_Structure__c[]"/>
	<!-- button to save or cancel -->
    <lightning:button variant="brand" label="Save Clones" onclick="{!c.SaveCloneGS}" />
    <lightning:button variant="brand" label="newGroupStructures values" onclick="{!c.CheckGS}" />
    <!-- Handle component initialization in a client-side controller -->
	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    	<!-- iterate over the newGroupStructures -->
 		<!-- <aura:iteration var="groupstructure" items="{!v.newGroupStructures}">   -->
       <lightning:layoutItem padding="horizontal-medium" size="12">
    <!-- Iterate over the list of Group Structures and display them -->
           <aura:iteration var="groupstructure" items="{!v.newGroupStructures}">
                  <c:GSCloneRecord groupstructure="{!groupstructure}"/>

Here is the GSCloneRecord component that is iterated on the main component.  I had a editrecordform here but could not get it to work so I switched to a card.  Still need to do work on the fields, etc.
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,lightning:isUrlAddressable" controller="GSController">
    <aura:attribute name="groupstructure" type="Group_Structure__c" />
	<!-- Handle component initialization in a client-side controller -->
	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

     <!-- Display the new contact form -->
    <div class="Create Contact">
        <lightning:card iconName="action:new_contact" title="Create Contact">
            <div class="slds-p-horizontal--small">
                <lightning:button variant="brand" label="groupstructure values" onclick="{!c.CheckGS}" />
                <lightning:input aura:id="contactField" label="Section" value="{!v.groupstructure.Section_Code__c}"/>
                <lightning:input aura:id="contactField" label="Package" value="{!v.groupstructure.Package_Code__c}"/>
                <lightning:input aura:id="contactField" label="Group Num" value="{!v.groupstructure.Group_Number__c}"/>

This component display properly.. the problem is that when there are two records, each record in the newgroupstructures attribute gets populated with teh same value.  If I enter a value in the section code field (for example)  whatever value I enter last gets populated to both records.

even before I save the record.. immediately after I enter a value, both records get updated with that value.  Any help would be greatly appreciated!! thanks!!!