2

My lightning:recordEditForm contains compound and regular (non-compound) fields. The regular fields display errors (field validation error, required field error, etc.) on the field. But, the compound fields behave differently. The compound fields always display errors at the top of the form in lightning:messages. How can I display the errors from the compound fields on the field rather than in lightning:messages?

<lightning:recordEditForm recordId="003XXXXXXXXXXXXXXX" objectApiName="Contact">
    <lightning:messages />
    <!-- regular field -->
    <lightning:outputField fieldName="Phone" />
    <!-- compound field -->
    <lightning:inputField fieldName="MailingAddress" />
    <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" />
</lightning:recordEditForm>

In the above code an error for the Phone field would show up on the field itself. For the compound field the error will show up at the top in lightning:messages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.