When selecting the list of option from available options in (lightning:dualListbox
) and move/push them to the selected options box or list. The entire component (lightning:recordEditForm
) gets refreshed. Not sure stop the refresh of parent component and do a custom handle function to save the selected option values inside the lightning:recordEditForm
Component
<aura:component controller="aacountIntialization" implements="force:appHostable,force:hasRecordId,force:hasSObjectName,flexipage:availableForRecordHome,lightning:actionOverride,force:lightningQuickAction" access="global" >
<!-- Attributes -->
<aura:attribute name="value" type="String" />
<aura:attribute name="arraySelected" type="String[]" />
<aura:attribute name="listOptions" type="List" default="[]"/>
<lightning:recordEditForm aura:id="editscreen" recordId="{!v.recordId}" objectApiName="Account">
<lightning:button class="slds-m-top_small" variant="neutral" label="Save" iconPosition="right" type="submit"/>
<lightning:dualListbox aura:id="multipleselectOptions" name="MultiSelectOptions" label="States"
sourceLabel="Available Options"
selectedLabel="Selected Options"
options="{! v.listOptions }"
value="{! v.arraySelected }" onchange="{! c.handleChange }"/>
</lightning:recordEditForm>
</aura:component>
Controller
handleChange : function (component, event, helper) {
var selectedOptionValue = event.getParam("value");
helper.arrayToMultistring(selectedOptionValue);
}
Helper
arrayToMultistring: function(selectedOptionValue){
var array = selectedOptionValue;
var str = "";
if(array.length>0){
for(var i in array){
console.log(array[i]);
str=str+array[i]+";";
}
}
component.set("v.arraySelected",str);
}
lightning:recordEditForm
has few more tags likelightning:inputField
, where i am directly saving all those fields onlightning:button type="submit"
. But when i have alightning:dualListbox
the entire recordeditform gets refresh when you move the selected options from left box to right