Skip to main content
I am adding and removing the row dynamically using list iteration.

 

<aura:iteration items="{!v.accList}" var="abc" indexVar="index">

<td>

<lightning:input aura:id="abc-start-date" name="accName" type="date" required="true" label="Date From" value="{!abc.Start_Date__c}" />

</td>

<td colspan="3">

<lightning:textarea aura:id="abc-comment" name="accComment" label="Comment" value="

{!abc.Comments__c}" placeholder="Comments"/>

</td>

</aura:iteration>

at helper/controller

 

for (var i = 0; i < accList.length; i++) {

conditioncheck

component.find('abc-comment').setCustomValidity("Comments can't be blank.");

component.find('abc-comment').reportValidity();

}

However, for multiple record it is failing as the abc-comment are multiple on the basis of list. Is there any way to put the validation message on the basis of record for which error/validation needs to be thrown
1 risposta
  1. 4 mag 2020, 07:41
    Hi Ashima,

    You need to set aura:id unique for every iterating var, you can set it as:

    aura:id="{!index + 'abc-start-date'}"
0/9000