You need to sign in to do that
Don't have an account?
Ashima nidhi
setCustomValidity and reportValidity at record level lightning component
I am adding and removing the row dynamically using list iteration.
at helper/controller
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
<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
You need to set aura:id unique for every iterating var, you can set it as:
aura:id="{!index + 'abc-start-date'}"