Pressing Cancel in UI does not restore the original value of field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aldisa
    Junior Member
    • Jun 2023
    • 28

    Pressing Cancel in UI does not restore the original value of field

    I am using a BeforeSave hook to validate/process edits made in the front-end.

    Here is the sequence of events:

    I click on the detail field pencil icon to start editing a field.
    After entering new value, I click on <Update> button.
    The back-end rejects the edit with an Error exception as follows:

    PHP Code:
    // generate UI error message
    throw Error::createWithBody(
      $error->getMessage(),
      Body::create('Update Error: ' . $error->getMessage())->encode()
    );
    
    The error is shown in UI and the edit does not complete.
    At this point the new value is in the field input still in edit mode.
    I click on the <Cancel> button.
    The field does NOT revert to the original value.
    If I refresh the page, now the field shows the original value since edit was never saved.

    Shouldn't the UI restore the original value in this situation?
  • yuri
    Member
    • Mar 2014
    • 8455

    #2
    Will be fixed in v8.3.2.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • aldisa
      Junior Member
      • Jun 2023
      • 28

      #3
      Thank you yuri.

      I have a related question.

      I have custom entity = MyEntity.
      This entity has a relationship to the Contact entity labeled as "Specialist Assigned".
      I have custom AfterUnrelate hook.

      The user unrelates a contact using detail edit:
      Click image for larger version

Name:	image.png
Views:	117
Size:	9.6 KB
ID:	107879
      When the user clicks on "X" to remove the Contact, and then clicks "Update", this will fire my AfterUnrelate​ hook.
      In my hook, I perform some validations, and is some circumstances, I may clear the values in other fields in MyEntity.

      However, in the UI those fields will have previous values since the hook was triggered with a detail edit.
      Is there anyway for the hook (backend code) to trigger a model sync and view reRender so that the altered values are updated in the view?

      Comment

      Working...