Yes. This is the correct way. Why did you ask about that other way in the other thread?
As I said in the other thread, *MAYBE* you could make a SJAX call (like AJAX, but synchronous) to save the <form> contents, but it would have to be unconditional: You would always do the save if warn is true.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.