0

Needing guidance on using a prebuilt lightning:recordeditform. I can't seem to get this to save the updates back to the record but can't see anything different when looking at similar solutions. Help would be greatly appreciated.

Controller:

    handleSubmit : function(cmp, event, helper) {
    var fields = event.getParam("fields");
    component.find('updateSettingForm').submit(fields);

Form:

    <lightning:recordEditForm 
        aura:id="updateSettingForm" 
        objectApiName="AppSetting__c" 
        recordId="{!v.appset.Id}" 
        onsubmit="{!c.handleSubmit}">

        <lightning:inputField fieldName="ConfigurationType__c" readonly="false"/>
        <lightning:inputField fieldName="Method__c" />

        <lightning:button variant="brand" label="SAVE" type="submit"/>
    </lightning:recordEditForm>

v.appset.Id is being populated via an Apex Class and passed back through an Init on load. This is working fine as the data from the EXISTING record is showing on the form as found within the queried record. When updating any field on the form it fails to commit back to the database.

1
  • 1
    You don't need onsubmit="{!c.handleSubmit}" and its corresponding code, if you are not going to check the user inputs and manipulate the values before submitting data. lightning:button of type="submit" should be enough to submit data. On the contrary, if you have some additional code within handleSubmit method, please include event.preventDefault() as its first line. This will stop the data from being submitted untill your code explicitly calls .submit(fields). Check if having event.preventDefault() solves your problem. Your code doesn't seem to have any other issues.
    – arut
    Dec 8 '20 at 4:47
0

Thank you Arut, upon your advise I removed the {!c.handleSubmit} and then I looked further at the code and decided to remove the following tag from the lightning:inputfield

readonly="false"

Despite being false this appears to have been stopping the update from occurring. I am not sure if this is expected but worth flagging.

Now updating!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.