Trying to using the new lightning:recordForm to create a new Contact record. Also have some validation rules against the Mailing Address fields.
When saving the record a generic error is displayed on the form "An error occurred while trying to update the record. Please try again" not the actual validation messages. A review of debug shows that the validation is failing.
How do I show these validation errors?
Same issue with the lightning:recordEditForm.
I have tried this, and my experience is that the first validation message is shown correctly at the spot where lightning:messages is listed in the form, but if the data is corrected and more validation rules fail, then the generic message again appears. My component code is fairly simple:
<lightning:recordEditForm aura:id="recordEditForm"
objectApiName="Contact">
<lightning:inputField fieldName="Name"/>
<lightning:inputField fieldName="Suffix"/>
<lightning:inputField fieldName="Phone"/>
<lightning:inputField fieldName="MobilePhone"/>
<lightning:inputField fieldName="MailingAddress"/>
<lightning:inputField fieldName="OtherAddress"/>
<lightning:messages />
<lightning:button class="slds-m-top_small" type="submit" name="save" label="Save" />
</lightning:recordEditForm>
And the debug shows:
10:18:36.15 (15826761)|VALIDATION_FAIL
10:18:36.15 (15848145)|VALIDATION_RULE|03d900000015B34|Mailing_Country_cannot_be_blank
But the form error only shows:
An error occurred while trying to update the record. Please try again.