Display uncorrect value (different from DB) after save

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Marco
    Junior Member
    • Sep 2017
    • 5

    Display uncorrect value (different from DB) after save

    Hello, I created entities and condition in my custom entity. I created a field with particular function before save: I create a control that save only if the field is in a correct standard, overwise the system returns an error. Everything is ok but then I insert an incorrect field and click to save, the gui show me the error (correct), the system does not save into database the uncorrect value (correct) but the windows go out from edit mode in show mode (not edit) and show on espo windows the uncorrect value even if it is not the value saved into DB.
    My custom control is store into custom/Espo/Custom/Repositories/customent.php Is it correct?
    I need that the system show the error, not go out from edit mode and not show the uncorrect value.
    The error function I used is: throw new Error('Codice immagine bolla ERRATO'); But it makes me out of editor mode, is it possible to use another function that not put me out?
    Thanks in advance
    Marco

  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello,
    it shows you the value from model. If you refresh the page, the value will be loaded from database.
    custom/Espo/Custom/Repositories/Customent.php (first upper)

    But, I think for this is better to validate the value on the frontend, but not on the backend (like other validation: required, int min and max, etc). This validation wont put you out of editing.



    If you don't want to change the way, set the fetched value to this field before throwing the error. But this will put you out, only you will see the correct value

    Comment

    Working...