fixes #4641 Related content missing when edit related content and cancel

Fixed the issue and committed the code for review, please check it. Tested on H2DB and Postgres.