0

I am trying to enter some value inside Description field, and I want to get the same text inside lightning:outputField as below:

<lightning:recordEditForm aura:id="recordEditForm" objectApiName="OrderItem">
    <div class="slds-grid slds-wrap">

        <lightning:inputField fieldName="Description__c" value="{!prod.OrderItem.Description__c}"/>
        <lightning:outputField fieldName="Description__c" value="{!prod.OrderItem.Description__c}"/>
    </div>
</lightning:recordEditForm>

But somehow I get this error message when I start typing.

enter image description here

I don't have any clue regarding this error. Can anybody tell me what is wrong with my code? I believe that if I enter a value in the inputfield, same changes should get reflected in outputfield coz both point to the same value property, i.e. {!prod.OrderItem.Description__c} in this case.

UPDATE: It looks like lightning:outputField component doesn't support value attribute, if its inside lightning:recordEditForm component. Is this true? I didn't find any example while browsing, but the important point is that the aura component doesn't give an error while saving the component. Even if the component is loaded, the component doesn't give an error.

1 Answer 1

1

lightning:outputField is specifically for displaying read-only value of fields related to a sobject and not for reflecting changes from other lightning:inputField. If you were to load the lightning:recordEditForm for a specific recordId, you would see that the field specified by lightning:outputField is displayed correctly. The changes done in the lightning:inputField would be stored locally or as draft sobject values (untill its committed to the DB) and not bound to lightning:outputField. It doesn't have any value attribute and you can check this in the specifications here.

For your requirement, consider using lightning:inputField with read-only attribute or one of the lightning:formatted* components (like lightning:formattedText). You can to write some JS code if the changes are not reflected automatically.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .