I have two picklist fields, Country(controllling picklist) and State(dependent picklsit). State should change based on Country value for my lightning page. As of now this is happening, but State field doesn't come on page when page gets load, it does when I make any change in Country Value. I want both the fields should be shown on page whenever page loads for first time and, also dependency should work.
Please find codes below -
CMP CODE:
<aura:attribute name="recordId" type="Id" access="public" />
<aura:attribute name="refreshFag" type="boolean" access="public" default="false" />
<div class="slds-grid slds-gutters" style="margin-left:2px;">
<table>
<tr>
<lightning:recordEditForm aura:id="recordViewForm" recordId="{!v.recordId}"
objectApiName="Opportunity">
<lightning:messages />
<td>
<label for="Country">Country</label>
<lightning:inputField aura:id="countyId" fieldName="Property_Country__c"
variant="label-hidden"
onchange="{!c.setStateRefresh}" />
</td>
<aura:if isTrue="{!v.refreshFag}">
<td>
<label for=" State / Province ">State / Province</label>
<lightning:inputField aura:id="stateId" fieldName="Property_State__c"
variant="label-hidden"/>
</td>
</aura:if>
</lightning:recordEditForm>
</tr>
</table>
</div><br/>
JS CODE:
setStateRefresh : function(component, event, helper) {
var refresh = component.set("v.refreshFag","true");
//alert('v.refreshFag---->'+refresh);
}